Skip to content

Commit

Permalink
Fix some issues compiling tests under MSVC/Windows.
Browse files Browse the repository at this point in the history
  - MSVC complains about "a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax".
  - MSVC complains when calling `set_*` on a proto bytes field with an `std::array` iterator.
  - Avoid implicit converstion of filesystem::path to string in tests.

PiperOrigin-RevId: 671051666
  • Loading branch information
jwcullen committed Sep 4, 2024
1 parent 78e5ee3 commit be33e44
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions iamf/cli/proto_to_obu/tests/codec_config_generator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ TEST_F(CodecConfigGeneratorTest, ObeysInvalidFlacStreamInfo) {
stream_info_metadata->set_minimum_frame_size(kInvalidMinimumFrameSize);
stream_info_metadata->set_maximum_frame_size(kInvalidMaximumFrameSize);
stream_info_metadata->set_number_of_channels(kInvalidNumberOfChannels);
stream_info_metadata->set_md5_signature(kInvalidMd5Signature.begin(),
stream_info_metadata->set_md5_signature(kInvalidMd5Signature.data(),
kInvalidMd5Signature.size());

const auto output_obus = InitAndGenerate();
Expand Down Expand Up @@ -801,7 +801,7 @@ TEST_F(CodecConfigGeneratorTest, ConfiguresFlacWithExtraBlocks) {
.mutable_codec_config()
->mutable_decoder_config_flac()
->add_metadata_blocks()));
const auto kExpectedPictureBlock = (FlacMetadataBlock){
const auto kExpectedPictureBlock = FlacMetadataBlock{
.header = {.last_metadata_block_flag = true,
.block_type = FlacMetaBlockHeader::kFlacPicture,
.metadata_data_block_length = 3},
Expand Down
1 change: 1 addition & 0 deletions iamf/cli/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ cc_test(
name = "iamf_components_test",
srcs = ["iamf_components_test.cc"],
deps = [
":cli_test_utils",
"//iamf/cli:iamf_components",
"//iamf/cli/proto:test_vector_metadata_cc_proto",
"//iamf/cli/proto:user_metadata_cc_proto",
Expand Down
10 changes: 5 additions & 5 deletions iamf/cli/tests/iamf_components_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#include "iamf/cli/iamf_components.h"

#include <cstdint>
#include <filesystem>
#include <optional>

#include "gtest/gtest.h"
#include "iamf/cli/proto/test_vector_metadata.pb.h"
#include "iamf/cli/proto/user_metadata.pb.h"
#include "iamf/cli/tests/cli_test_utils.h"
#include "src/google/protobuf/text_format.h"

namespace iamf_tools {
Expand All @@ -36,8 +36,8 @@ TEST(IamfComponentsTest, CreateMixPresentationFinalizerReturnsNonNull) {

TEST(IamfComponentsTest,
CreateObuSequencersReturnsNonNullAndNonZeroObuSequencers) {
auto obu_sequencers =
CreateObuSequencers({}, std::filesystem::temp_directory_path(), false);
auto obu_sequencers = CreateObuSequencers(
{}, GetAndCreateOutputDirectory("iamf_directory"), false);

EXPECT_FALSE(obu_sequencers.empty());
for (auto& obu_sequencer : obu_sequencers) {
Expand All @@ -57,7 +57,7 @@ TEST(IamfComponentsTest, CanBeConfiguredWithFixedSizeLebGenerator) {
true);

auto obu_sequencers = CreateObuSequencers(
user_metadata, std::filesystem::temp_directory_path(), false);
user_metadata, GetAndCreateOutputDirectory("iamf_directory"), false);

EXPECT_FALSE(obu_sequencers.empty());
for (auto& obu_sequencer : obu_sequencers) {
Expand All @@ -84,7 +84,7 @@ TEST(IamfComponentsTest, ReturnsEmptyListWhenLebGeneratorIsInvalid) {
true);

auto obu_sequencers = CreateObuSequencers(
user_metadata, std::filesystem::temp_directory_path(), false);
user_metadata, GetAndCreateOutputDirectory("iamf_directory"), false);

EXPECT_TRUE(obu_sequencers.empty());
}
Expand Down
19 changes: 11 additions & 8 deletions iamf/cli/tests/wav_reader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ TEST(CreateFromFile, SucceedsOnValidAdmFile) {
}

TEST(CreateFromFile, SucceedsOnValidWavFile) {
const auto input_wav_file = std::filesystem::current_path() /
std::string("iamf/cli/testdata/") /
"stereo_8_samples_48khz_s16le.wav";
const auto input_wav_file =
(std::filesystem::current_path() / std::string("iamf/cli/testdata/") /
"stereo_8_samples_48khz_s16le.wav")
.string();
ASSERT_TRUE(std::filesystem::exists(input_wav_file));

EXPECT_THAT(
Expand All @@ -100,9 +101,10 @@ TEST(CreateFromFile, SucceedsOnValidWavFile) {

TEST(CreateFromFile, FailsWhenNumSamplesPerFrameIsZero) {
const size_t kInvalidNumSamplesPerFrame = 0;
const auto input_wav_file = std::filesystem::current_path() /
std::string("iamf/cli/testdata/") /
"stereo_8_samples_48khz_s16le.wav";
const auto input_wav_file =
(std::filesystem::current_path() / std::string("iamf/cli/testdata/") /
"stereo_8_samples_48khz_s16le.wav")
.string();
ASSERT_TRUE(std::filesystem::exists(input_wav_file));

EXPECT_FALSE(
Expand Down Expand Up @@ -131,8 +133,9 @@ TEST(CreateFromFile, FailsOnNonWavFile) {

WavReader InitAndValidate(const std::filesystem::path& filename,
const size_t num_samples_per_frame) {
const auto input_wav_file = std::filesystem::current_path() /
std::string("iamf/cli/testdata/") / filename;
const auto input_wav_file = (std::filesystem::current_path() /
std::string("iamf/cli/testdata/") / filename)
.string();
auto wav_reader =
WavReader::CreateFromFile(input_wav_file, num_samples_per_frame);
EXPECT_THAT(wav_reader, IsOk());
Expand Down
5 changes: 3 additions & 2 deletions iamf/cli/tests/wav_sample_provider_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ void InitializeTestData(
audio_elements);
}

std::filesystem::path GetInputWavDir() {
std::string GetInputWavDir() {
static const auto input_wav_dir =
std::filesystem::current_path() / std::string("iamf/cli/testdata");
(std::filesystem::current_path() / std::string("iamf/cli/testdata"))
.string();
return input_wav_dir;
}

Expand Down

0 comments on commit be33e44

Please sign in to comment.