Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/UnitTestsSources/UnitTestsMain.cpp Tue Oct 30 13:53:29 2018 +0100 +++ b/UnitTestsSources/UnitTestsMain.cpp Tue Oct 30 16:16:07 2018 +0100 @@ -301,30 +301,30 @@ TEST(Uri, AutodetectMimeType) { - ASSERT_EQ("", SystemToolbox::AutodetectMimeType("../NOTES")); - ASSERT_EQ("", SystemToolbox::AutodetectMimeType("")); - ASSERT_EQ("", SystemToolbox::AutodetectMimeType("/")); - ASSERT_EQ("", SystemToolbox::AutodetectMimeType("a/a")); - ASSERT_EQ("", SystemToolbox::AutodetectMimeType("..\\a\\")); - ASSERT_EQ("", SystemToolbox::AutodetectMimeType("..\\a\\a")); + ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("../NOTES")); + ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("")); + ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("/")); + ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("a/a")); + ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("..\\a\\")); + ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("..\\a\\a")); - ASSERT_EQ("text/plain", SystemToolbox::AutodetectMimeType("../NOTES.txt")); - ASSERT_EQ("text/plain", SystemToolbox::AutodetectMimeType("../coucou.xml/NOTES.txt")); - ASSERT_EQ("application/xml", SystemToolbox::AutodetectMimeType("..\\coucou.\\NOTES.xml")); - ASSERT_EQ("application/xml", SystemToolbox::AutodetectMimeType("../.xml")); - ASSERT_EQ("application/xml", SystemToolbox::AutodetectMimeType("../.XmL")); + ASSERT_EQ(MimeType_PlainText, SystemToolbox::AutodetectMimeType("../NOTES.txt")); + ASSERT_EQ(MimeType_PlainText, SystemToolbox::AutodetectMimeType("../coucou.xml/NOTES.txt")); + ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("..\\coucou.\\NOTES.xml")); + ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("../.xml")); + ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("../.XmL")); - ASSERT_EQ("application/javascript", SystemToolbox::AutodetectMimeType("NOTES.js")); - ASSERT_EQ("application/json", SystemToolbox::AutodetectMimeType("NOTES.json")); - ASSERT_EQ("application/pdf", SystemToolbox::AutodetectMimeType("NOTES.pdf")); - ASSERT_EQ("text/css", SystemToolbox::AutodetectMimeType("NOTES.css")); - ASSERT_EQ("text/html", SystemToolbox::AutodetectMimeType("NOTES.html")); - ASSERT_EQ("text/plain", SystemToolbox::AutodetectMimeType("NOTES.txt")); - ASSERT_EQ("application/xml", SystemToolbox::AutodetectMimeType("NOTES.xml")); - ASSERT_EQ("image/gif", SystemToolbox::AutodetectMimeType("NOTES.gif")); - ASSERT_EQ("image/jpeg", SystemToolbox::AutodetectMimeType("NOTES.jpg")); - ASSERT_EQ("image/jpeg", SystemToolbox::AutodetectMimeType("NOTES.jpeg")); - ASSERT_EQ("image/png", SystemToolbox::AutodetectMimeType("NOTES.png")); + ASSERT_EQ(MimeType_JavaScript, SystemToolbox::AutodetectMimeType("NOTES.js")); + ASSERT_EQ(MimeType_Json, SystemToolbox::AutodetectMimeType("NOTES.json")); + ASSERT_EQ(MimeType_Pdf, SystemToolbox::AutodetectMimeType("NOTES.pdf")); + ASSERT_EQ(MimeType_Css, SystemToolbox::AutodetectMimeType("NOTES.css")); + ASSERT_EQ(MimeType_Html, SystemToolbox::AutodetectMimeType("NOTES.html")); + ASSERT_EQ(MimeType_PlainText, SystemToolbox::AutodetectMimeType("NOTES.txt")); + ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("NOTES.xml")); + ASSERT_EQ(MimeType_Gif, SystemToolbox::AutodetectMimeType("NOTES.gif")); + ASSERT_EQ(MimeType_Jpeg, SystemToolbox::AutodetectMimeType("NOTES.jpg")); + ASSERT_EQ(MimeType_Jpeg, SystemToolbox::AutodetectMimeType("NOTES.jpeg")); + ASSERT_EQ(MimeType_Png, SystemToolbox::AutodetectMimeType("NOTES.png")); } TEST(Toolbox, ComputeMD5) @@ -709,6 +709,26 @@ ASSERT_EQ(JobState_Paused, StringToJobState(EnumerationToString(JobState_Paused))); ASSERT_EQ(JobState_Retry, StringToJobState(EnumerationToString(JobState_Retry))); ASSERT_THROW(StringToJobState("nope"), OrthancException); + + ASSERT_EQ(MimeType_Binary, StringToMimeType(EnumerationToString(MimeType_Binary))); + ASSERT_EQ(MimeType_Dicom, StringToMimeType(EnumerationToString(MimeType_Dicom))); + ASSERT_EQ(MimeType_Jpeg, StringToMimeType(EnumerationToString(MimeType_Jpeg))); + ASSERT_EQ(MimeType_Jpeg2000, StringToMimeType(EnumerationToString(MimeType_Jpeg2000))); + ASSERT_EQ(MimeType_Json, StringToMimeType(EnumerationToString(MimeType_Json))); + ASSERT_EQ(MimeType_Pdf, StringToMimeType(EnumerationToString(MimeType_Pdf))); + ASSERT_EQ(MimeType_Png, StringToMimeType(EnumerationToString(MimeType_Png))); + ASSERT_EQ(MimeType_Xml, StringToMimeType(EnumerationToString(MimeType_Xml))); + ASSERT_EQ(MimeType_Xml, StringToMimeType("application/xml")); + ASSERT_EQ(MimeType_Xml, StringToMimeType("text/xml")); + ASSERT_EQ(MimeType_PlainText, StringToMimeType(EnumerationToString(MimeType_PlainText))); + ASSERT_EQ(MimeType_Pam, StringToMimeType(EnumerationToString(MimeType_Pam))); + ASSERT_EQ(MimeType_Html, StringToMimeType(EnumerationToString(MimeType_Html))); + ASSERT_EQ(MimeType_Gzip, StringToMimeType(EnumerationToString(MimeType_Gzip))); + ASSERT_EQ(MimeType_JavaScript, StringToMimeType(EnumerationToString(MimeType_JavaScript))); + ASSERT_EQ(MimeType_Gif, StringToMimeType(EnumerationToString(MimeType_Gif))); + ASSERT_EQ(MimeType_WebAssembly, StringToMimeType(EnumerationToString(MimeType_WebAssembly))); + ASSERT_EQ(MimeType_Css, StringToMimeType(EnumerationToString(MimeType_Css))); + ASSERT_THROW(StringToMimeType("nope"), OrthancException); }