diff options
Diffstat (limited to 'cpp/src/tests')
-rw-r--r-- | cpp/src/tests/Blob.cpp | 32 | ||||
-rw-r--r-- | cpp/src/tests/FieldTable.cpp | 84 | ||||
-rw-r--r-- | cpp/src/tests/FieldTableTest.cpp | 96 | ||||
-rw-r--r-- | cpp/src/tests/FieldValue.cpp | 79 | ||||
-rw-r--r-- | cpp/src/tests/Makefile.am | 11 | ||||
-rw-r--r-- | cpp/src/tests/ValueTest.cpp | 102 |
6 files changed, 189 insertions, 215 deletions
diff --git a/cpp/src/tests/Blob.cpp b/cpp/src/tests/Blob.cpp index 96861a3670..eeb2fa693b 100644 --- a/cpp/src/tests/Blob.cpp +++ b/cpp/src/tests/Blob.cpp @@ -1,21 +1,21 @@ /* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ - #include "qpid/framing/Blob.h" #define BOOST_AUTO_TEST_MAIN diff --git a/cpp/src/tests/FieldTable.cpp b/cpp/src/tests/FieldTable.cpp new file mode 100644 index 0000000000..31e3b08cba --- /dev/null +++ b/cpp/src/tests/FieldTable.cpp @@ -0,0 +1,84 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include <iostream> +#include "qpid/framing/FieldTable.h" +#include "qpid/framing/FieldValue.h" + +#define BOOST_AUTO_TEST_MAIN +#include <boost/test/auto_unit_test.hpp> + +using namespace qpid::framing; + +BOOST_AUTO_TEST_CASE(testMe) +{ + FieldTable ft; + ft.setString("A", "BCDE"); + BOOST_CHECK(StringValue("BCDE") == *ft.get("A")); + + char buff[100]; + Buffer wbuffer(buff, 100); + wbuffer.put(ft); + + Buffer rbuffer(buff, 100); + FieldTable ft2; + rbuffer.get(ft2); + BOOST_CHECK(StringValue("BCDE") == *ft2.get("A")); + +} + +BOOST_AUTO_TEST_CASE(testAssignment) +{ + FieldTable a; + FieldTable b; + + a.setString("A", "BBBB"); + a.setInt("B", 1234); + b = a; + a.setString("A", "CCCC"); + + BOOST_CHECK(StringValue("CCCC") == *a.get("A")); + BOOST_CHECK(StringValue("BBBB") == *b.get("A")); + BOOST_CHECK_EQUAL(1234, a.getInt("B")); + BOOST_CHECK_EQUAL(1234, b.getInt("B")); + BOOST_CHECK(IntegerValue(1234) == *a.get("B")); + BOOST_CHECK(IntegerValue(1234) == *b.get("B")); + + FieldTable d; + { + FieldTable c; + c = a; + + char* buff = static_cast<char*>(::alloca(c.size())); + Buffer wbuffer(buff, c.size()); + wbuffer.put(c); + + Buffer rbuffer(buff, c.size()); + rbuffer.get(d); + BOOST_CHECK_EQUAL(c, d); + BOOST_CHECK(StringValue("CCCC") == *c.get("A")); + BOOST_CHECK(IntegerValue(1234) == *c.get("B")); + } + BOOST_CHECK(StringValue("CCCC") == *d.get("A")); + BOOST_CHECK(IntegerValue(1234) == *d.get("B")); +} + + + diff --git a/cpp/src/tests/FieldTableTest.cpp b/cpp/src/tests/FieldTableTest.cpp deleted file mode 100644 index b2efb23954..0000000000 --- a/cpp/src/tests/FieldTableTest.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include <iostream> -#include "qpid/framing/FieldTable.h" -#include "qpid/framing/FieldValue.h" - -#include "qpid_test_plugin.h" - -using namespace qpid::framing; - -class FieldTableTest : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(FieldTableTest); - CPPUNIT_TEST(testMe); - CPPUNIT_TEST(testAssignment); - CPPUNIT_TEST_SUITE_END(); - - public: - - void testMe() - { - FieldTable ft; - ft.setString("A", "BCDE"); - CPPUNIT_ASSERT(StringValue("BCDE") == *ft.get("A")); - - char buff[100]; - Buffer wbuffer(buff, 100); - wbuffer.put(ft); - - Buffer rbuffer(buff, 100); - FieldTable ft2; - rbuffer.get(ft2); - CPPUNIT_ASSERT(StringValue("BCDE") == *ft2.get("A")); - - } - - void testAssignment() - { - FieldTable a; - FieldTable b; - - a.setString("A", "BBBB"); - a.setInt("B", 1234); - b = a; - a.setString("A", "CCCC"); - - CPPUNIT_ASSERT(StringValue("CCCC") == *a.get("A")); - CPPUNIT_ASSERT(StringValue("BBBB") == *b.get("A")); - CPPUNIT_ASSERT_EQUAL(1234, a.getInt("B")); - CPPUNIT_ASSERT_EQUAL(1234, b.getInt("B")); - CPPUNIT_ASSERT(IntegerValue(1234) == *a.get("B")); - CPPUNIT_ASSERT(IntegerValue(1234) == *b.get("B")); - - FieldTable d; - { - FieldTable c; - c = a; - - char* buff = static_cast<char*>(::alloca(c.size())); - Buffer wbuffer(buff, c.size()); - wbuffer.put(c); - - Buffer rbuffer(buff, c.size()); - rbuffer.get(d); - CPPUNIT_ASSERT_EQUAL(c, d); - CPPUNIT_ASSERT(StringValue("CCCC") == *c.get("A")); - CPPUNIT_ASSERT(IntegerValue(1234) == *c.get("B")); - } - CPPUNIT_ASSERT(StringValue("CCCC") == *d.get("A")); - CPPUNIT_ASSERT(IntegerValue(1234) == *d.get("B")); - } -}; - - -// Make this test suite a plugin. -CPPUNIT_PLUGIN_IMPLEMENT(); -CPPUNIT_TEST_SUITE_REGISTRATION(FieldTableTest); - diff --git a/cpp/src/tests/FieldValue.cpp b/cpp/src/tests/FieldValue.cpp new file mode 100644 index 0000000000..f2a859c95e --- /dev/null +++ b/cpp/src/tests/FieldValue.cpp @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +#include "qpid/framing/FieldValue.h" + +#define BOOST_AUTO_TEST_MAIN +#include <boost/test/auto_unit_test.hpp> + +using namespace qpid::framing; + +StringValue s("abc"); +IntegerValue i(42); +//DecimalValue d(1234,2); +//FieldTableValue ft; +//EmptyValue e; + +BOOST_AUTO_TEST_CASE(testStringValueEquals) +{ + + BOOST_CHECK(StringValue("abc") == s); + BOOST_CHECK(StringValue("foo") != s); + BOOST_CHECK(s != i); +// BOOST_CHECK(s != ft); +} + +BOOST_AUTO_TEST_CASE(testIntegerValueEquals) +{ + BOOST_CHECK(IntegerValue(42) == i); + BOOST_CHECK(IntegerValue(5) != i); + BOOST_CHECK(i != s); +// BOOST_CHECK(i != ft); +} + +#if 0 +BOOST_AUTO_TEST_CASE(testDecimalValueEquals) +{ + BOOST_CHECK(DecimalValue(1234, 2) == d); + BOOST_CHECK(DecimalValue(12345, 2) != d); + BOOST_CHECK(DecimalValue(1234, 3) != d); + BOOST_CHECK(d != s); +} + +BOOST_AUTO_TEST_CASE(testFieldTableValueEquals) +{ + ft.getValue().setString("foo", "FOO"); + ft.getValue().setInt("magic", 7); + + BOOST_CHECK_EQUAL(std::string("FOO"), + ft.getValue().getString("foo")); + BOOST_CHECK_EQUAL(7, ft.getValue().getInt("magic")); + + FieldTableValue f2; + BOOST_CHECK(ft != f2); + f2.getValue().setString("foo", "FOO"); + BOOST_CHECK(ft != f2); + f2.getValue().setInt("magic", 7); + BOOST_CHECK_EQUAL(ft,f2); + BOOST_CHECK(ft == f2); + f2.getValue().setString("foo", "BAR"); + BOOST_CHECK(ft != f2); + BOOST_CHECK(ft != i); +} +#endif + diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am index eea2e6570a..b484bc19c7 100644 --- a/cpp/src/tests/Makefile.am +++ b/cpp/src/tests/Makefile.am @@ -60,6 +60,16 @@ check_PROGRAMS+=Shlib Shlib_SOURCES=Shlib.cpp Shlib_LDADD=-lboost_unit_test_framework $(lib_common) +TESTS+=FieldValue +check_PROGRAMS+=FieldValue +FieldValue_SOURCES=FieldValue.cpp +FieldValue_LDADD=-lboost_unit_test_framework $(lib_common) + +TESTS+=FieldTable +check_PROGRAMS+=FieldTable +FieldTable_SOURCES=FieldTable.cpp +FieldTable_LDADD=-lboost_unit_test_framework $(lib_common) + # TODO aconway 2007-08-07: Why aren't these tests run automatically? check_PROGRAMS+=ConcurrentQueue @@ -106,7 +116,6 @@ broker_unit_tests = \ ClientChannelTest framing_unit_tests = \ - FieldTableTest \ FramingTest \ HeaderTest \ SequenceNumberTest diff --git a/cpp/src/tests/ValueTest.cpp b/cpp/src/tests/ValueTest.cpp deleted file mode 100644 index 7e767b8559..0000000000 --- a/cpp/src/tests/ValueTest.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -#include "qpid/framing/Value.h" -#include "qpid_test_plugin.h" - -using namespace qpid::framing; - - -class ValueTest : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(ValueTest); - CPPUNIT_TEST(testStringValueEquals); - CPPUNIT_TEST(testIntegerValueEquals); - CPPUNIT_TEST(testDecimalValueEquals); - CPPUNIT_TEST(testFieldTableValueEquals); - CPPUNIT_TEST_SUITE_END(); - - StringValue s; - IntegerValue i; - DecimalValue d; - FieldTableValue ft; - EmptyValue e; - - public: - ValueTest() : - s("abc"), - i(42), - d(1234,2) - - { - ft.getValue().setString("foo", "FOO"); - ft.getValue().setInt("magic", 7); - } - - void testStringValueEquals() - { - - CPPUNIT_ASSERT(StringValue("abc") == s); - CPPUNIT_ASSERT(s != StringValue("foo")); - CPPUNIT_ASSERT(s != e); - CPPUNIT_ASSERT(e != d); - CPPUNIT_ASSERT(e != ft); - } - - void testIntegerValueEquals() - { - CPPUNIT_ASSERT(IntegerValue(42) == i); - CPPUNIT_ASSERT(IntegerValue(5) != i); - CPPUNIT_ASSERT(i != e); - CPPUNIT_ASSERT(i != d); - } - - void testDecimalValueEquals() - { - CPPUNIT_ASSERT(DecimalValue(1234, 2) == d); - CPPUNIT_ASSERT(DecimalValue(12345, 2) != d); - CPPUNIT_ASSERT(DecimalValue(1234, 3) != d); - CPPUNIT_ASSERT(d != s); - } - - - void testFieldTableValueEquals() - { - CPPUNIT_ASSERT_EQUAL(std::string("FOO"), - ft.getValue().getString("foo")); - CPPUNIT_ASSERT_EQUAL(7, ft.getValue().getInt("magic")); - - FieldTableValue f2; - CPPUNIT_ASSERT(ft != f2); - f2.getValue().setString("foo", "FOO"); - CPPUNIT_ASSERT(ft != f2); - f2.getValue().setInt("magic", 7); - CPPUNIT_ASSERT_EQUAL(ft,f2); - CPPUNIT_ASSERT(ft == f2); - f2.getValue().setString("foo", "BAR"); - CPPUNIT_ASSERT(ft != f2); - CPPUNIT_ASSERT(ft != i); - } - -}; - - -// Make this test suite a plugin. -CPPUNIT_PLUGIN_IMPLEMENT(); -CPPUNIT_TEST_SUITE_REGISTRATION(ValueTest); - |