Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.cpp')
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.cpp
new file mode 100644
index 000000000..453334af2
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.cpp
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "PairTest.h"
+
+#include "common/containers/Pair.h"
+#include "common/containers/String.h"
+#include "util/etAssert.h"
+
+using namespace etRuntime;
+
+void PairTest::testConstructors(void) {
+ Pair<int, int> p1;
+ EXPECT_EQUAL_INT32(m_caseId, "p1.first", 0, p1.first);
+ EXPECT_EQUAL_INT32(m_caseId, "p1.second", 0, p1.second);
+
+ Pair<int, int> p2(1, 2);
+ EXPECT_EQUAL_INT32(m_caseId, "p1.first", 1, p2.first);
+ EXPECT_EQUAL_INT32(m_caseId, "p1.second", 2, p2.second);
+
+ Pair<int, String> p3;
+ EXPECT_EQUAL_INT32(m_caseId, "p1.first", 0, p3.first);
+ EXPECT_TRUE(m_caseId, "p1.second", p3.second=="");
+
+ Pair<int, String> p4(123, "pair");
+ EXPECT_EQUAL_INT32(m_caseId, "p1.first", 123, p4.first);
+ EXPECT_TRUE(m_caseId, "p1.second", p4.second=="pair");
+}
+
+void PairTest::testOperators(void) {
+ Pair<int, int> p1(2,2), p2(1, 1);
+ EXPECT_TRUE(m_caseId, "p1>p2", p1>p2);
+ EXPECT_TRUE(m_caseId, "!p1<p2", !(p1<p2));
+ EXPECT_TRUE(m_caseId, "p1!=p2", p1!=p2);
+
+ p1.first = 1;
+ EXPECT_TRUE(m_caseId, "p1>p2", p1>p2);
+ EXPECT_TRUE(m_caseId, "!p1<p2", !(p1<p2));
+ EXPECT_TRUE(m_caseId, "p1!=p2", p1!=p2);
+
+ p1.second = 1;
+ EXPECT_TRUE(m_caseId, "!p1>p2", !(p1>p2));
+ EXPECT_TRUE(m_caseId, "!p1<p2", !(p1<p2));
+ EXPECT_TRUE(m_caseId, "p1>=p2", p1>=p2);
+ EXPECT_TRUE(m_caseId, "p1<=p2", p1<=p2);
+ EXPECT_TRUE(m_caseId, "p1==p2", p1==p2);
+}
+
+void PairTest::runAllTestCases() {
+ ADD_TESTCASE_CPP(testConstructors)
+ ADD_TESTCASE_CPP(testOperators)
+}

Back to the top