summaryrefslogtreecommitdiff
path: root/libdeno/file_util_test.cc
blob: 3f01c8115a6939db4de0efd7c00374aff4908eea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// 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"));
}

// TODO(ry) success unit test. Needs a tempfile or fixture.
// TEST(FileUtilTest, ReadFileToStringSuccess) { }