Use std::string_view instead of absl::string_view in fixture.cc.
Clean up some lint warnings. Fixes #1306. PiperOrigin-RevId: 595988916 Change-Id: I0e8584ff8704ea7294cf649664ab447cb1d4ff46
This commit is contained in:
committed by
Copybara-Service
parent
ca023a6f28
commit
c59a33dd81
@@ -57,7 +57,6 @@ target_compile_definitions(fixture PUBLIC MJSTATIC)
|
||||
target_link_libraries(
|
||||
fixture
|
||||
PUBLIC absl::core_headers
|
||||
absl::strings
|
||||
absl::synchronization
|
||||
gtest
|
||||
gmock
|
||||
|
||||
+6
-3
@@ -14,11 +14,14 @@
|
||||
|
||||
#include "test/fixture.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
@@ -107,7 +110,7 @@ mjModel* LoadModelFromPath(const char* model_path) {
|
||||
return model;
|
||||
}
|
||||
|
||||
const std::string GetFileContents(const char* path) {
|
||||
std::string GetFileContents(const char* path) {
|
||||
std::ifstream ifs;
|
||||
ifs.open(path, std::ifstream::in);
|
||||
EXPECT_FALSE(ifs.fail());
|
||||
@@ -116,7 +119,7 @@ const std::string GetFileContents(const char* path) {
|
||||
return sstream.str();
|
||||
}
|
||||
|
||||
const std::string SaveAndReadXml(const mjModel* model) {
|
||||
std::string SaveAndReadXml(const mjModel* model) {
|
||||
EXPECT_THAT(model, testing::NotNull());
|
||||
|
||||
constexpr int kMaxPathLen = 1024;
|
||||
|
||||
+5
-7
@@ -17,13 +17,11 @@
|
||||
|
||||
#include <csetjmp>
|
||||
#include <cstring>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <absl/strings/string_view.h>
|
||||
#include <mujoco/mjdata.h>
|
||||
#include <mujoco/mjmodel.h>
|
||||
#include <mujoco/mujoco.h>
|
||||
|
||||
@@ -80,14 +78,14 @@ auto MjuErrorMessageFrom(Return (*func)(Args...)) {
|
||||
}
|
||||
|
||||
// Returns a path to a data file, under the mujoco/test directory.
|
||||
const std::string GetTestDataFilePath(absl::string_view path);
|
||||
const std::string GetTestDataFilePath(std::string_view path);
|
||||
|
||||
// Returns a path to a data file, under the mujoco/model directory.
|
||||
const std::string GetModelPath(absl::string_view path);
|
||||
const std::string GetModelPath(std::string_view path);
|
||||
|
||||
// Returns a newly-allocated mjModel, loaded from the contents of xml.
|
||||
// On failure returns nullptr and populates the error array if present.
|
||||
mjModel* LoadModelFromString(absl::string_view xml, char* error = nullptr,
|
||||
mjModel* LoadModelFromString(std::string_view xml, char* error = nullptr,
|
||||
int error_size = 0, mjVFS* vfs = nullptr);
|
||||
|
||||
// Returns a newly-allocated mjModel, loaded from the contents in model_path.
|
||||
@@ -95,7 +93,7 @@ mjModel* LoadModelFromString(absl::string_view xml, char* error = nullptr,
|
||||
mjModel* LoadModelFromPath(const char* model_path);
|
||||
|
||||
// Returns a string loaded from first saving the model given an input.
|
||||
const std::string SaveAndReadXml(const mjModel* model);
|
||||
std::string SaveAndReadXml(const mjModel* model);
|
||||
|
||||
// Adds control noise.
|
||||
std::vector<mjtNum> GetCtrlNoise(const mjModel* m, int nsteps,
|
||||
|
||||
Reference in New Issue
Block a user