blob: 6d4acd1d812c133358519019f9b46ee422248b8e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
#include "testing/gtest/include/gtest/gtest.h"
#include "file_util.h"
TEST(FileUtilTest, ReadFileToStringFileNotExist) {
std::string output;
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) { }
|