mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2025-08-03 12:50:02 +00:00
Use karma to make mime strings from structs.
This commit is contained in:
parent
4ff6719077
commit
009341233d
3 changed files with 122 additions and 9 deletions
|
@ -24,16 +24,16 @@ namespace {
|
|||
}
|
||||
} //unnamed namespace
|
||||
|
||||
TEST_CASE ("Test the Mime-type splitter", "[mime][parser]") {
|
||||
TEST_CASE ("Test the string_to_mime parser", "[mime][parser]") {
|
||||
using tawashi::SplitMime;
|
||||
using tawashi::split_mime;
|
||||
using tawashi::string_to_mime;
|
||||
|
||||
bool ok;
|
||||
int parsed_count;
|
||||
{
|
||||
std::string test("application/x-javascript; charset=UTF-8");
|
||||
std::string curr_val;
|
||||
SplitMime split = split_mime(&test, ok, parsed_count);
|
||||
SplitMime split = string_to_mime(&test, ok, parsed_count);
|
||||
|
||||
REQUIRE(ok);
|
||||
CHECK(test.size() == parsed_count);
|
||||
|
@ -49,7 +49,7 @@ TEST_CASE ("Test the Mime-type splitter", "[mime][parser]") {
|
|||
{
|
||||
std::string test("image/jpeg; filename=genome.jpeg; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
|
||||
std::string curr_val;
|
||||
SplitMime split = split_mime(&test, ok, parsed_count);
|
||||
SplitMime split = string_to_mime(&test, ok, parsed_count);
|
||||
|
||||
REQUIRE(ok);
|
||||
CHECK(test.size() == parsed_count);
|
||||
|
@ -66,3 +66,40 @@ TEST_CASE ("Test the Mime-type splitter", "[mime][parser]") {
|
|||
CHECK(curr_val == "Wed, 12 Feb 1997 16:29:51 -0500");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE ("Test the mime_to_string parser", "[mime][parser]") {
|
||||
using tawashi::SplitMime;
|
||||
using tawashi::mime_to_string;
|
||||
|
||||
std::string type = "image";
|
||||
std::string subtype = "jpeg";
|
||||
bool ok;
|
||||
|
||||
{
|
||||
SplitMime test;
|
||||
test.type = type;
|
||||
test.subtype = subtype;
|
||||
std::string result = mime_to_string(test, ok);
|
||||
REQUIRE(ok);
|
||||
CHECK(result == "image/jpeg");
|
||||
}
|
||||
{
|
||||
SplitMime test;
|
||||
test.type = type;
|
||||
test.subtype = subtype;
|
||||
test.parameters["filename"] = "genome.jpeg";
|
||||
std::string result = mime_to_string(test, ok);
|
||||
REQUIRE(ok);
|
||||
CHECK(result == "image/jpeg; filename=genome.jpeg");
|
||||
}
|
||||
{
|
||||
SplitMime test;
|
||||
test.type = type;
|
||||
test.subtype = subtype;
|
||||
test.parameters["modification-date"] = "Wed, 12 Feb 1997 16:29:51 -0500";
|
||||
test.parameters["filename"] = "genome.jpeg";
|
||||
std::string result = mime_to_string(test, ok);
|
||||
REQUIRE(ok);
|
||||
CHECK(result == "image/jpeg; filename=genome.jpeg; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue