aboutsummaryrefslogtreecommitdiff
path: root/0.4.0/paludis/version_operator_TEST.cc
diff options
context:
space:
mode:
Diffstat (limited to '0.4.0/paludis/version_operator_TEST.cc')
-rw-r--r--0.4.0/paludis/version_operator_TEST.cc114
1 files changed, 114 insertions, 0 deletions
diff --git a/0.4.0/paludis/version_operator_TEST.cc b/0.4.0/paludis/version_operator_TEST.cc
new file mode 100644
index 000000000..94d9a3937
--- /dev/null
+++ b/0.4.0/paludis/version_operator_TEST.cc
@@ -0,0 +1,114 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/version_operator.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace test;
+using namespace paludis;
+
+/** \file
+ * Test cases for version_operator.hh.
+ *
+ * \ingroup grptestcases
+ */
+
+namespace test_cases
+{
+ /**
+ * \test Test VersionOperator creation and assignment.
+ *
+ * \ingroup grptestcases
+ */
+ struct VersionOperatorTest : TestCase
+ {
+ VersionOperatorTest() : TestCase("version operator") { }
+
+ void run()
+ {
+ VersionOperator v1(vo_greater);
+ VersionOperator v2(vo_less_equal);
+ TEST_CHECK(v1 != v2);
+ TEST_CHECK(v1 == vo_greater);
+ TEST_CHECK(v1 != vo_less_equal);
+ TEST_CHECK(v2 == vo_less_equal);
+ TEST_CHECK(v2 != vo_greater);
+
+ VersionOperator v3(v1);
+ TEST_CHECK(v1 == vo_greater);
+ TEST_CHECK(v3 == vo_greater);
+ TEST_CHECK(v1 == v3);
+
+ v3 = v2;
+ TEST_CHECK(v1 != v3);
+ TEST_CHECK(v1 != v2);
+ TEST_CHECK(v2 == v3);
+ TEST_CHECK(v1 == vo_greater);
+ TEST_CHECK(v2 == vo_less_equal);
+ TEST_CHECK(v3 == vo_less_equal);
+ }
+ } test_version_operator;
+
+ /**
+ * \test Test VersionOperator creation and assignment from a string.
+ *
+ * \ingroup grptestcases
+ */
+ struct VersionOperatorFromStringTest : TestCase
+ {
+ VersionOperatorFromStringTest() : TestCase("version operator from string") { }
+
+ void run()
+ {
+ VersionOperator v1(">");
+ VersionOperator v2("<=");
+ TEST_CHECK(v1 != v2);
+ TEST_CHECK(v1 == vo_greater);
+ TEST_CHECK(v1 != vo_less_equal);
+ TEST_CHECK(v2 == vo_less_equal);
+ TEST_CHECK(v2 != vo_greater);
+
+ TEST_CHECK_EQUAL(VersionOperator("<"), VersionOperator(vo_less));
+ TEST_CHECK_EQUAL(VersionOperator("<="), VersionOperator(vo_less_equal));
+ TEST_CHECK_EQUAL(VersionOperator("="), VersionOperator(vo_equal));
+ TEST_CHECK_EQUAL(VersionOperator("~"), VersionOperator(vo_tilde));
+ TEST_CHECK_EQUAL(VersionOperator(">"), VersionOperator(vo_greater));
+ TEST_CHECK_EQUAL(VersionOperator(">="), VersionOperator(vo_greater_equal));
+ }
+ } test_version_operator_from_string;
+
+ /**
+ * \test Test VersionOperator stringification.
+ *
+ * \ingroup grptestcases
+ */
+ struct VersionOperatorToStringTest : TestCase
+ {
+ VersionOperatorToStringTest() : TestCase("version operator to string") { }
+
+ void run()
+ {
+ TEST_CHECK_EQUAL(stringify(VersionOperator(vo_greater)), ">");
+ TEST_CHECK_EQUAL(stringify(VersionOperator(vo_equal)), "=");
+ TEST_CHECK_EQUAL(stringify(VersionOperator(vo_tilde)), "~");
+ }
+ } test_version_operator_to_string;
+}
+