summaryrefslogtreecommitdiffstats
path: root/mmc_updater/src/tests/TestUtils.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-06-07 21:10:18 +0200
committerPetr Mrázek <peterix@gmail.com>2015-06-07 21:10:18 +0200
commit6d7bff2476459049f4f554291a680e0f6003ea66 (patch)
tree4202e9f1cd843197648fec93b48a5bc88407dc2e /mmc_updater/src/tests/TestUtils.h
parent977e11ef8d6780b173ad5ca6d13e29e721d0c6a0 (diff)
downloadMultiMC-6d7bff2476459049f4f554291a680e0f6003ea66.tar
MultiMC-6d7bff2476459049f4f554291a680e0f6003ea66.tar.gz
MultiMC-6d7bff2476459049f4f554291a680e0f6003ea66.tar.lz
MultiMC-6d7bff2476459049f4f554291a680e0f6003ea66.tar.xz
MultiMC-6d7bff2476459049f4f554291a680e0f6003ea66.zip
GH-1060 remove updater code
Diffstat (limited to 'mmc_updater/src/tests/TestUtils.h')
-rw-r--r--mmc_updater/src/tests/TestUtils.h108
1 files changed, 0 insertions, 108 deletions
diff --git a/mmc_updater/src/tests/TestUtils.h b/mmc_updater/src/tests/TestUtils.h
deleted file mode 100644
index 68d97da5..00000000
--- a/mmc_updater/src/tests/TestUtils.h
+++ /dev/null
@@ -1,108 +0,0 @@
-#pragma once
-
-#include <iostream>
-#include <functional>
-#include <string>
-#include <vector>
-
-template <class T>
-class TestList
-{
- public:
- void addTest(void (T::*test)())
- {
- m_tests.push_back(std::mem_fun(test));
- }
-
- int size() const
- {
- return m_tests.size();
- }
-
- void runTest(T* testInstance, int i)
- {
- m_tests.at(i)(testInstance);
- }
-
- private:
- std::vector<std::mem_fun_t<void,T> > m_tests;
-};
-
-class TestUtils
-{
- public:
- template <class X, class Y>
- static void compare(const X& x, const Y& y, const char* xString, const char* yString)
- {
- if (x != y)
- {
- throw "Actual and expected values differ. "
- "Actual: " + toString(x,xString) +
- " Expected: " + toString(y,yString);
- }
- }
-
- template <typename T>
- static std::string toString(T value, const char* context)
- {
- return "Unprintable: " + std::string(context);
- }
-
- template <class T>
- static int runTest(class TestList<T>& tests) throw ()
- {
- std::string errorText;
- try
- {
- T testInstance;
- for (int i=0; i < tests.size(); i++)
- {
- tests.runTest(&testInstance,i);
- }
- }
- catch (const std::exception& ex)
- {
- errorText = ex.what();
- }
- catch (const std::string& error)
- {
- errorText = error;
- }
- catch (...)
- {
- errorText = "Unknown exception";
- }
-
- if (errorText.empty())
- {
- std::cout << "Test passed" << std::endl;
- return 0;
- }
- else
- {
- std::cout << "Test failed: " << errorText << std::endl;
- return 1;
- }
- }
-};
-
-template <>
-inline std::string TestUtils::toString(const std::string& value, const char*)
-{
- return value;
-}
-template <>
-inline std::string TestUtils::toString(std::string value, const char*)
-{
- return value;
-}
-template <>
-inline std::string TestUtils::toString(const char* value, const char*)
-{
- return value;
-}
-
-#define TEST_COMPARE(x,y) \
- TestUtils::compare(x,y,#x,#y);
-
-