From c6ae3f7abce4b0b26c29fada76a0aed5c226fed7 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 13 Jul 2018 01:21:28 -0400 Subject: Add deno::Basename and deno::BinaryContentAsC utilies. These are prep for code sharing with the asset code soon to land. --- src/file_util_test.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/file_util_test.cc') diff --git a/src/file_util_test.cc b/src/file_util_test.cc index 3b1c3e239..33d635881 100644 --- a/src/file_util_test.cc +++ b/src/file_util_test.cc @@ -9,5 +9,21 @@ TEST(FileUtilTest, ReadFileToStringFileNotExist) { EXPECT_FALSE(deno::ReadFileToString("/should_error_out.txt", &output)); } +TEST(FileUtilTest, Basename) { + EXPECT_EQ("foo.txt", deno::Basename("foo.txt")); + EXPECT_EQ("foo.txt", deno::Basename("/foo.txt")); + EXPECT_EQ("", deno::Basename("/")); + EXPECT_EQ("foo.txt", deno::Basename(".\\foo.txt")); + EXPECT_EQ("foo.txt", deno::Basename("/home/ryan/foo.txt")); + EXPECT_EQ("foo.txt", deno::Basename("C:\\home\\ryan\\foo.txt")); +} + +TEST(FileUtilTest, BinaryContentAsC) { + auto c_code = deno::BinaryContentAsC("aaa", std::string("bbb")); + EXPECT_TRUE(c_code.find("static const char aaa_data[]") != std::string::npos); + EXPECT_TRUE(c_code.find("static const int aaa_size = 3;") != + std::string::npos); +} + // TODO(ry) success unit test. Needs a tempfile or fixture. // TEST(FileUtilTest, ReadFileToStringSuccess) { } -- cgit v1.2.3