summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Figuière <hub@figuiere.net>2017-01-09 22:04:58 -0500
committerHubert Figuière <hub@figuiere.net>2017-01-09 22:57:07 -0500
commit11cc2a3544b07cc4dd1a145290d88566010f77a0 (patch)
treeb51e481fbb9fab60f95be9001924e39c16a9b95e
parent76b97fd75ac323b03f0d45bdcb3d53d85b89ba8e (diff)
tests: add more test for the Adobe SDK
-rw-r--r--exempi/tests/test-adobesdk.cpp76
1 files changed, 62 insertions, 14 deletions
diff --git a/exempi/tests/test-adobesdk.cpp b/exempi/tests/test-adobesdk.cpp
index 38c214e..e9aff4d 100644
--- a/exempi/tests/test-adobesdk.cpp
+++ b/exempi/tests/test-adobesdk.cpp
@@ -1,27 +1,75 @@
-#include <boost/test/minimal.hpp>
+
+
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MAIN
+
+#include <boost/test/unit_test.hpp>
#include "../../XMPCore/source/XMPUtils.hpp"
using boost::unit_test::test_suite;
-// void test_xmpfiles()
-int test_main(int argc, char* argv[])
+struct Fixture {
+ Fixture() {
+ XMPMeta::Initialize();
+ }
+ ~Fixture() {
+ XMPMeta::Terminate();
+ }
+};
+
+BOOST_GLOBAL_FIXTURE(Fixture);
+
+BOOST_AUTO_TEST_SUITE(test_adobesdk)
+
+BOOST_AUTO_TEST_CASE(test_composeArray)
{
+ XMP_VarString fullPath;
+ BOOST_CHECK_THROW(XMPUtils::ComposeArrayItemPath("", "myArray",
+ 42, &fullPath), XMP_Error);
+ BOOST_CHECK_THROW(XMPUtils::ComposeArrayItemPath("http://ns.figuiere.net/test/", "myArray",
+ 42, &fullPath), XMP_Error);
+ BOOST_CHECK_THROW(XMPUtils::ComposeArrayItemPath(kXMP_NS_DC, "",
+ 42, &fullPath), XMP_Error);
- XMP_Int64 value = XMPUtils::ConvertToInt64("0x123456");
- BOOST_CHECK(value == 0x123456);
+ XMPUtils::ComposeArrayItemPath(kXMP_NS_DC, "myArray",
+ 42, &fullPath);
+ BOOST_CHECK(fullPath == "myArray[42]");
+
+ XMPUtils::ComposeArrayItemPath(kXMP_NS_DC, "myArray",
+ kXMP_ArrayLastItem, &fullPath);
+ BOOST_CHECK(fullPath == "myArray[last()]");
+}
+
+BOOST_AUTO_TEST_CASE(test_composeStructFieldPath)
+{
+ XMP_VarString fullPath;
+
+ BOOST_CHECK_THROW(XMPUtils::ComposeStructFieldPath("", "struct",
+ kXMP_NS_XML, "field", &fullPath), XMP_Error);
+ BOOST_CHECK_THROW(XMPUtils::ComposeStructFieldPath(kXMP_NS_DC, "struct",
+ "", "field", &fullPath), XMP_Error);
+ BOOST_CHECK_THROW(XMPUtils::ComposeStructFieldPath(kXMP_NS_DC, "",
+ kXMP_NS_XML, "field", &fullPath), XMP_Error);
+ BOOST_CHECK_THROW(XMPUtils::ComposeStructFieldPath(kXMP_NS_DC, "struct",
+ kXMP_NS_XML, "", &fullPath), XMP_Error);
+
+ XMPUtils::ComposeStructFieldPath(kXMP_NS_DC, "struct",
+ kXMP_NS_XML, "field", &fullPath);
+ BOOST_CHECK(fullPath == "struct/xml:field");
+}
+
+BOOST_AUTO_TEST_CASE(test_convertToInt64)
+{
+ XMP_Int64 value = XMPUtils::ConvertToInt64("0x123456789012345");
+ BOOST_CHECK(value == 0x123456789012345);
value = XMPUtils::ConvertToInt64("123456");
BOOST_CHECK(value == 123456);
- bool did_throw = false;
- try {
- value = XMPUtils::ConvertToInt64("abcdef");
- } catch(const XMP_Error & e) {
- did_throw = true;
- }
- BOOST_CHECK(did_throw);
-
- return 0;
+ BOOST_CHECK_THROW(XMPUtils::ConvertToInt64("abcdef"), XMP_Error);
}
+
+
+BOOST_AUTO_TEST_SUITE_END()