mpd/test/TestUriExtract.cxx

23 lines
663 B
C++
Raw Normal View History

2019-08-09 15:54:13 +02:00
/*
* Unit tests for src/util/
*/
#include "util/UriExtract.hxx"
#include <gtest/gtest.h>
using std::string_view_literals::operator""sv;
2019-08-09 15:54:13 +02:00
TEST(UriExtract, Suffix)
{
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
/* eliminate the query string */
EXPECT_EQ(uri_get_suffix("/foo/bar.jpg?query_string"), "jpg"sv);
2019-08-09 15:54:13 +02:00
}