<commit_before>/******************************************************************************
 * Copyright 2018 The Apollo 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 <gtest/gtest.h>

#define private public
#define protected public
#include "modules/perception/common/io/io_util.h"

namespace apollo {
namespace perception {
namespace common {

TEST(CommonIoTest, read_pose_file) {
  const std::string testdata_folder =
      "modules/perception/testdata/common/io/params/";
  std::string filename;
  Eigen::Affine3d pose;
  int frame_id = 0;
  double time_stamp = 0;

  EXPECT_FALSE(ReadPoseFile(filename, nullptr, nullptr, nullptr));
  EXPECT_FALSE(ReadPoseFile(filename, &pose, &frame_id, &time_stamp));

  filename = testdata_folder + "pose_file.txt";
  EXPECT_TRUE(ReadPoseFile(filename, &pose, &frame_id, &time_stamp));
}

/* TODO(all): to be fixed
TEST(CommonIoTest, load_camera_intrinsic) {
  const std::string testdata_folder =
      "modules/perception/testdata/common/io/params/";
  std::string yaml_file;
  base::BrownCameraDistortionModel model;

  EXPECT_FALSE(LoadBrownCameraIntrinsic(yaml_file, nullptr));
  EXPECT_FALSE(LoadBrownCameraIntrinsic(yaml_file, &model));

  yaml_file = testdata_folder + "empty.yaml";
  EXPECT_FALSE(LoadBrownCameraIntrinsic(yaml_file, &model));

  yaml_file = testdata_folder + "test.yaml";
  EXPECT_TRUE(LoadBrownCameraIntrinsic(yaml_file, &model));
  EXPECT_EQ(model.width_, 1192);
  EXPECT_EQ(model.height_, 712);
}
*/
/* TODO(all): to be fixed
TEST(CommonIoTest, load_ocamera_intrinsic) {
  const std::string testdata_folder =
      "modules/perception/testdata/common/io/params/";
  std::string yaml_file;
  base::OmnidirectionalCameraDistortionModel model;

  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, nullptr));
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));

  yaml_file = testdata_folder + "empty.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));

  yaml_file = testdata_folder + "test_ocam.yaml";
  EXPECT_TRUE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  EXPECT_EQ(model.width_, 1920);
  EXPECT_EQ(model.height_, 1080);

  yaml_file = testdata_folder + "test_ocam1.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam2.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam3.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam4.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam5.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam6.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam7.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam8.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
}
*/

}  // namespace common
}  // namespace perception
}  // namespace apollo<commit_msg>Perception: added unit test of perception/common/io<commit_after>/******************************************************************************
 * Copyright 2018 The Apollo 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 <gtest/gtest.h>

#define private public
#define protected public
#include "modules/perception/common/io/io_util.h"

namespace apollo {
namespace perception {
namespace common {

TEST(CommonIoTest, read_pose_file) {
  const std::string testdata_folder =
      "modules/perception/testdata/common/io/params/";
  std::string filename;
  Eigen::Affine3d pose;
  int frame_id = 0;
  double time_stamp = 0;

  EXPECT_FALSE(ReadPoseFile(filename, nullptr, nullptr, nullptr));
  EXPECT_FALSE(ReadPoseFile(filename, &pose, &frame_id, &time_stamp));

  filename = testdata_folder + "pose_file.txt";
  EXPECT_TRUE(ReadPoseFile(filename, &pose, &frame_id, &time_stamp));
}

TEST(CommonIoTest, load_camera_intrinsic) {
  const std::string testdata_folder =
      "modules/perception/testdata/common/io/params/";
  std::string yaml_file;
  base::BrownCameraDistortionModel model;

  EXPECT_FALSE(LoadBrownCameraIntrinsic(yaml_file, nullptr));
  EXPECT_FALSE(LoadBrownCameraIntrinsic(yaml_file, &model));

  yaml_file = testdata_folder + "empty.yaml";
  EXPECT_FALSE(LoadBrownCameraIntrinsic(yaml_file, &model));

  yaml_file = testdata_folder + "test.yaml";
  EXPECT_TRUE(LoadBrownCameraIntrinsic(yaml_file, &model));
  EXPECT_EQ(model.width_, 1192);
  EXPECT_EQ(model.height_, 712);
}

TEST(CommonIoTest, load_ocamera_intrinsic) {
  const std::string testdata_folder =
      "modules/perception/testdata/common/io/params/";
  std::string yaml_file;
  base::OmnidirectionalCameraDistortionModel model;

  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, nullptr));
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));

  yaml_file = testdata_folder + "empty.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));

  yaml_file = testdata_folder + "test_ocam.yaml";
  EXPECT_TRUE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  EXPECT_EQ(model.width_, 1920);
  EXPECT_EQ(model.height_, 1080);

  yaml_file = testdata_folder + "test_ocam1.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam2.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam3.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam4.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam5.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam6.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam7.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
  yaml_file = testdata_folder + "test_ocam8.yaml";
  EXPECT_FALSE(LoadOmnidirectionalCameraIntrinsics(yaml_file, &model));
}

}  // namespace common
}  // namespace perception
}  // namespace apollo
{'fraction_non_alphanumeric': 0.14137618245432163, 'fraction_numerical': 0.008811714396786316, 'mean_word_length': 6.500485908649174, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3860569', 'n_tokens_mistral': 2549, 'n_tokens_neox': 2418, 'n_words': 484}