comparison UnitTestsSources/UnitTestsMain.cpp @ 2908:9d277f8ad698

new enumeration: MimeType
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Oct 2018 16:16:07 +0100
parents 0204af4ece6a
children ad0e7def3338
comparison
equal deleted inserted replaced
2907:0204af4ece6a 2908:9d277f8ad698
299 ASSERT_TRUE(Toolbox::IsChildUri(c5, c5)); 299 ASSERT_TRUE(Toolbox::IsChildUri(c5, c5));
300 } 300 }
301 301
302 TEST(Uri, AutodetectMimeType) 302 TEST(Uri, AutodetectMimeType)
303 { 303 {
304 ASSERT_EQ("", SystemToolbox::AutodetectMimeType("../NOTES")); 304 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("../NOTES"));
305 ASSERT_EQ("", SystemToolbox::AutodetectMimeType("")); 305 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType(""));
306 ASSERT_EQ("", SystemToolbox::AutodetectMimeType("/")); 306 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("/"));
307 ASSERT_EQ("", SystemToolbox::AutodetectMimeType("a/a")); 307 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("a/a"));
308 ASSERT_EQ("", SystemToolbox::AutodetectMimeType("..\\a\\")); 308 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("..\\a\\"));
309 ASSERT_EQ("", SystemToolbox::AutodetectMimeType("..\\a\\a")); 309 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("..\\a\\a"));
310 310
311 ASSERT_EQ("text/plain", SystemToolbox::AutodetectMimeType("../NOTES.txt")); 311 ASSERT_EQ(MimeType_PlainText, SystemToolbox::AutodetectMimeType("../NOTES.txt"));
312 ASSERT_EQ("text/plain", SystemToolbox::AutodetectMimeType("../coucou.xml/NOTES.txt")); 312 ASSERT_EQ(MimeType_PlainText, SystemToolbox::AutodetectMimeType("../coucou.xml/NOTES.txt"));
313 ASSERT_EQ("application/xml", SystemToolbox::AutodetectMimeType("..\\coucou.\\NOTES.xml")); 313 ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("..\\coucou.\\NOTES.xml"));
314 ASSERT_EQ("application/xml", SystemToolbox::AutodetectMimeType("../.xml")); 314 ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("../.xml"));
315 ASSERT_EQ("application/xml", SystemToolbox::AutodetectMimeType("../.XmL")); 315 ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("../.XmL"));
316 316
317 ASSERT_EQ("application/javascript", SystemToolbox::AutodetectMimeType("NOTES.js")); 317 ASSERT_EQ(MimeType_JavaScript, SystemToolbox::AutodetectMimeType("NOTES.js"));
318 ASSERT_EQ("application/json", SystemToolbox::AutodetectMimeType("NOTES.json")); 318 ASSERT_EQ(MimeType_Json, SystemToolbox::AutodetectMimeType("NOTES.json"));
319 ASSERT_EQ("application/pdf", SystemToolbox::AutodetectMimeType("NOTES.pdf")); 319 ASSERT_EQ(MimeType_Pdf, SystemToolbox::AutodetectMimeType("NOTES.pdf"));
320 ASSERT_EQ("text/css", SystemToolbox::AutodetectMimeType("NOTES.css")); 320 ASSERT_EQ(MimeType_Css, SystemToolbox::AutodetectMimeType("NOTES.css"));
321 ASSERT_EQ("text/html", SystemToolbox::AutodetectMimeType("NOTES.html")); 321 ASSERT_EQ(MimeType_Html, SystemToolbox::AutodetectMimeType("NOTES.html"));
322 ASSERT_EQ("text/plain", SystemToolbox::AutodetectMimeType("NOTES.txt")); 322 ASSERT_EQ(MimeType_PlainText, SystemToolbox::AutodetectMimeType("NOTES.txt"));
323 ASSERT_EQ("application/xml", SystemToolbox::AutodetectMimeType("NOTES.xml")); 323 ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("NOTES.xml"));
324 ASSERT_EQ("image/gif", SystemToolbox::AutodetectMimeType("NOTES.gif")); 324 ASSERT_EQ(MimeType_Gif, SystemToolbox::AutodetectMimeType("NOTES.gif"));
325 ASSERT_EQ("image/jpeg", SystemToolbox::AutodetectMimeType("NOTES.jpg")); 325 ASSERT_EQ(MimeType_Jpeg, SystemToolbox::AutodetectMimeType("NOTES.jpg"));
326 ASSERT_EQ("image/jpeg", SystemToolbox::AutodetectMimeType("NOTES.jpeg")); 326 ASSERT_EQ(MimeType_Jpeg, SystemToolbox::AutodetectMimeType("NOTES.jpeg"));
327 ASSERT_EQ("image/png", SystemToolbox::AutodetectMimeType("NOTES.png")); 327 ASSERT_EQ(MimeType_Png, SystemToolbox::AutodetectMimeType("NOTES.png"));
328 } 328 }
329 329
330 TEST(Toolbox, ComputeMD5) 330 TEST(Toolbox, ComputeMD5)
331 { 331 {
332 std::string s; 332 std::string s;
707 ASSERT_EQ(JobState_Success, StringToJobState(EnumerationToString(JobState_Success))); 707 ASSERT_EQ(JobState_Success, StringToJobState(EnumerationToString(JobState_Success)));
708 ASSERT_EQ(JobState_Failure, StringToJobState(EnumerationToString(JobState_Failure))); 708 ASSERT_EQ(JobState_Failure, StringToJobState(EnumerationToString(JobState_Failure)));
709 ASSERT_EQ(JobState_Paused, StringToJobState(EnumerationToString(JobState_Paused))); 709 ASSERT_EQ(JobState_Paused, StringToJobState(EnumerationToString(JobState_Paused)));
710 ASSERT_EQ(JobState_Retry, StringToJobState(EnumerationToString(JobState_Retry))); 710 ASSERT_EQ(JobState_Retry, StringToJobState(EnumerationToString(JobState_Retry)));
711 ASSERT_THROW(StringToJobState("nope"), OrthancException); 711 ASSERT_THROW(StringToJobState("nope"), OrthancException);
712
713 ASSERT_EQ(MimeType_Binary, StringToMimeType(EnumerationToString(MimeType_Binary)));
714 ASSERT_EQ(MimeType_Dicom, StringToMimeType(EnumerationToString(MimeType_Dicom)));
715 ASSERT_EQ(MimeType_Jpeg, StringToMimeType(EnumerationToString(MimeType_Jpeg)));
716 ASSERT_EQ(MimeType_Jpeg2000, StringToMimeType(EnumerationToString(MimeType_Jpeg2000)));
717 ASSERT_EQ(MimeType_Json, StringToMimeType(EnumerationToString(MimeType_Json)));
718 ASSERT_EQ(MimeType_Pdf, StringToMimeType(EnumerationToString(MimeType_Pdf)));
719 ASSERT_EQ(MimeType_Png, StringToMimeType(EnumerationToString(MimeType_Png)));
720 ASSERT_EQ(MimeType_Xml, StringToMimeType(EnumerationToString(MimeType_Xml)));
721 ASSERT_EQ(MimeType_Xml, StringToMimeType("application/xml"));
722 ASSERT_EQ(MimeType_Xml, StringToMimeType("text/xml"));
723 ASSERT_EQ(MimeType_PlainText, StringToMimeType(EnumerationToString(MimeType_PlainText)));
724 ASSERT_EQ(MimeType_Pam, StringToMimeType(EnumerationToString(MimeType_Pam)));
725 ASSERT_EQ(MimeType_Html, StringToMimeType(EnumerationToString(MimeType_Html)));
726 ASSERT_EQ(MimeType_Gzip, StringToMimeType(EnumerationToString(MimeType_Gzip)));
727 ASSERT_EQ(MimeType_JavaScript, StringToMimeType(EnumerationToString(MimeType_JavaScript)));
728 ASSERT_EQ(MimeType_Gif, StringToMimeType(EnumerationToString(MimeType_Gif)));
729 ASSERT_EQ(MimeType_WebAssembly, StringToMimeType(EnumerationToString(MimeType_WebAssembly)));
730 ASSERT_EQ(MimeType_Css, StringToMimeType(EnumerationToString(MimeType_Css)));
731 ASSERT_THROW(StringToMimeType("nope"), OrthancException);
712 } 732 }
713 733
714 734
715 735
716 #if defined(__linux__) || defined(__OpenBSD__) 736 #if defined(__linux__) || defined(__OpenBSD__)