/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow/core/platform/resource_loader.h"

#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/status.h"
#include "tensorflow/core/platform/test.h"

namespace tensorflow {

const char kDataDependencyPath[] = "tensorflow/core/platform/resource_loader.h";

TEST(ResourceLoaderTest, FindsAndOpensFile) {
  string filepath = GetDataDependencyFilepath(kDataDependencyPath);
  Status s = Env::Default()->FileExists(filepath);
  EXPECT_TRUE(s.ok()) << "No file found at this location: " << filepath;
}

}  // namespace tensorflow

/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow/core/platform/resource_loader.h"

#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/path.h"
#include "tensorflow/core/platform/status.h"
#include "tensorflow/core/platform/test.h"

namespace tensorflow {
namespace {

string DataDependencyPath() {
  return io::JoinPath("tensorflow", "core", "platform", "resource_loader.h");
}

TEST(ResourceLoaderTest, FindsAndOpensFile) {
  string filepath = GetDataDependencyFilepath(DataDependencyPath());
  Status s = Env::Default()->FileExists(filepath);
  EXPECT_TRUE(s.ok()) << "No file found at this location: " << filepath;
}

}  // namespace
}  // namespace tensorflow

Use JoinPath over a fixed string for building paths.
Use JoinPath over a fixed string for building paths.

The fixed path doesn't work well on Windows when the correct path separator is used.

PiperOrigin-RevId: 296095586
Change-Id: I9fe0459ef58a310bf471cf2548b3f7e23b764502
