test_namespace.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "test.h"
  2. #include "namespace.h"
  3. static int
  4. test_namespace()
  5. {
  6. LSUP_NSMap *nsm = LSUP_nsmap_new();
  7. ASSERT (nsm != NULL, "Error creating namespace map!");
  8. EXPECT_PASS (
  9. LSUP_nsmap_add (nsm, "dc", "http://purl.org/dc/elements/1.1/"));
  10. EXPECT_PASS (LSUP_nsmap_add (nsm, "dcterms", "http://purl.org/dc/terms/"));
  11. EXPECT_STR_EQ (
  12. LSUP_nsmap_get (nsm, "dc"), "http://purl.org/dc/elements/1.1/");
  13. EXPECT_STR_EQ (
  14. LSUP_nsmap_get (nsm, "dcterms"), "http://purl.org/dc/terms/");
  15. // Prefixes longer than 7 chars are truncated.
  16. ASSERT (
  17. LSUP_nsmap_get (nsm, "dctermsxxx") == NULL,
  18. "Non-existent NS found!");
  19. ASSERT (LSUP_nsmap_get (nsm, "none") == NULL, "Non-existent NS found!");
  20. EXPECT_PASS (LSUP_nsmap_remove (nsm, "dc"));
  21. ASSERT (
  22. LSUP_nsmap_remove (nsm, "none") == LSUP_NOACTION,
  23. "Wrong result for removal of non-existent prefix!");
  24. ASSERT (LSUP_nsmap_get (nsm, "dc") == NULL, "Deleted NS found!");
  25. LSUP_nsmap_free (nsm);
  26. return 0;
  27. }
  28. int namespace_tests()
  29. {
  30. RUN (test_namespace);
  31. return 0;
  32. }