2019-08-09 15:54:13 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for src/util/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "util/UriExtract.hxx"
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
2020-11-04 20:39:06 +01:00
|
|
|
using std::string_view_literals::operator""sv;
|
|
|
|
|
2019-08-09 15:54:13 +02:00
|
|
|
TEST(UriExtract, Suffix)
|
|
|
|
{
|
2020-11-04 20:39:06 +01:00
|
|
|
EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo/bar").data());
|
|
|
|
EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo.jpg/bar").data());
|
|
|
|
EXPECT_EQ(uri_get_suffix("/foo/bar.jpg"), "jpg"sv);
|
|
|
|
EXPECT_EQ(uri_get_suffix("/foo.png/bar.jpg"), "jpg"sv);
|
|
|
|
EXPECT_EQ((const char *)nullptr, uri_get_suffix(".jpg").data());
|
|
|
|
EXPECT_EQ((const char *)nullptr, uri_get_suffix("/foo/.jpg").data());
|
2019-08-09 15:54:13 +02:00
|
|
|
|
2020-11-04 20:39:06 +01:00
|
|
|
/* eliminate the query string */
|
|
|
|
EXPECT_EQ(uri_get_suffix("/foo/bar.jpg?query_string"), "jpg"sv);
|
2019-08-09 15:54:13 +02:00
|
|
|
}
|