blob: 33d63588100577e4a08e96c8958676c99d89c783 (
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
29
|
// Copyright 2018 Ryan Dahl <ry@tinyclouds.org>
// 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) { }
|