Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
73 lines
2.3 KiB
C++
73 lines
2.3 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include "ui/humanstrings.h"
|
|
|
|
TEST(UIHumanStrings, SampleRateToStringAppendsHz)
|
|
{
|
|
EXPECT_EQ(olive::HumanStrings::sample_rate_to_string(44100),
|
|
QStringLiteral("44100 Hz"));
|
|
EXPECT_EQ(olive::HumanStrings::sample_rate_to_string(48000),
|
|
QStringLiteral("48000 Hz"));
|
|
EXPECT_EQ(olive::HumanStrings::sample_rate_to_string(0), QStringLiteral("0 Hz"));
|
|
}
|
|
|
|
TEST(UIHumanStrings, KnownChannelLayoutsHaveNames)
|
|
{
|
|
EXPECT_EQ(olive::HumanStrings::channel_layout_to_string(
|
|
olive::k_channel_layout_mono),
|
|
QStringLiteral("Mono"));
|
|
EXPECT_EQ(olive::HumanStrings::channel_layout_to_string(
|
|
olive::k_channel_layout_stereo),
|
|
QStringLiteral("Stereo"));
|
|
EXPECT_EQ(olive::HumanStrings::channel_layout_to_string(
|
|
olive::k_channel_layout2_1),
|
|
QStringLiteral("2.1"));
|
|
EXPECT_EQ(olive::HumanStrings::channel_layout_to_string(
|
|
olive::k_channel_layout5_point1),
|
|
QStringLiteral("5.1"));
|
|
EXPECT_EQ(olive::HumanStrings::channel_layout_to_string(
|
|
olive::k_channel_layout7_point1),
|
|
QStringLiteral("7.1"));
|
|
}
|
|
|
|
TEST(UIHumanStrings, UnknownChannelLayoutFallsBackToHex)
|
|
{
|
|
const QString s = olive::HumanStrings::channel_layout_to_string(0x1234);
|
|
|
|
EXPECT_TRUE(s.startsWith(QStringLiteral("Unknown (0x")));
|
|
EXPECT_TRUE(s.contains(QStringLiteral("1234")));
|
|
}
|
|
|
|
TEST(UIHumanStrings, AllSampleFormatsHaveNonEmptyNames)
|
|
{
|
|
using olive::core::SampleFormat;
|
|
|
|
for (SampleFormat fmt :
|
|
{ SampleFormat::u8, SampleFormat::s16, SampleFormat::s32,
|
|
SampleFormat::s64, SampleFormat::f32, SampleFormat::f64,
|
|
SampleFormat::u8_p, SampleFormat::s16_p, SampleFormat::s32_p,
|
|
SampleFormat::s64_p, SampleFormat::f32_p, SampleFormat::f64_p }) {
|
|
const QString s = olive::HumanStrings::format_to_string(fmt);
|
|
EXPECT_FALSE(s.isEmpty());
|
|
EXPECT_FALSE(s.startsWith(QStringLiteral("Unknown")));
|
|
}
|
|
}
|
|
|
|
TEST(UIHumanStrings, PackedAndPlanarFormatsAreDistinguished)
|
|
{
|
|
using olive::core::SampleFormat;
|
|
|
|
EXPECT_TRUE(olive::HumanStrings::format_to_string(SampleFormat::f32)
|
|
.contains(QStringLiteral("Packed")));
|
|
EXPECT_TRUE(olive::HumanStrings::format_to_string(SampleFormat::f32_p)
|
|
.contains(QStringLiteral("Planar")));
|
|
}
|
|
|
|
TEST(UIHumanStrings, InvalidSampleFormatFallsBackToHex)
|
|
{
|
|
const QString s = olive::HumanStrings::format_to_string(
|
|
olive::core::SampleFormat::invalid);
|
|
|
|
EXPECT_TRUE(s.startsWith(QStringLiteral("Unknown (0x")));
|
|
}
|