FreeCAD WebAssembly development snapshot
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
This commit is contained in:
12
tests/src/Mod/Start/App/CMakeLists.txt
Normal file
12
tests/src/Mod/Start/App/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
add_executable(Start_tests_run
|
||||
FileUtilities.cpp
|
||||
ThumbnailSource.cpp
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
Start_tests_run
|
||||
PUBLIC
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
96
tests/src/Mod/Start/App/FileUtilities.cpp
Normal file
96
tests/src/Mod/Start/App/FileUtilities.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "src/App/InitApplication.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <Mod/Start/App/FileUtilities.h>
|
||||
|
||||
|
||||
class FileUtilitiesTest: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestSuite()
|
||||
{
|
||||
tests::initApplication();
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{}
|
||||
|
||||
void TearDown() override
|
||||
{}
|
||||
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizeZeroBytes)
|
||||
{
|
||||
auto result = Start::humanReadableSize(0);
|
||||
EXPECT_EQ(result, "0 B");
|
||||
}
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizeBytesHasNoDecimal)
|
||||
{
|
||||
constexpr uint64_t smallNumberOfBytes {512};
|
||||
auto result = Start::humanReadableSize(smallNumberOfBytes);
|
||||
EXPECT_EQ(result.find('.'), std::string::npos);
|
||||
}
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizeOthersHaveDecimal)
|
||||
{
|
||||
constexpr std::array<uint64_t, 6> testSizes {
|
||||
1000,
|
||||
123456,
|
||||
123456789,
|
||||
123456789013,
|
||||
100000000000000,
|
||||
std::numeric_limits<uint64_t>::max()
|
||||
};
|
||||
for (const auto size : testSizes) {
|
||||
auto result = Start::humanReadableSize(size);
|
||||
EXPECT_NE(result.find('.'), std::string::npos);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizeB)
|
||||
{
|
||||
EXPECT_EQ("999 B", Start::humanReadableSize(999));
|
||||
}
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizekB)
|
||||
{
|
||||
EXPECT_EQ("1.0 kB", Start::humanReadableSize(1000));
|
||||
}
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizekBSignificantDigits)
|
||||
{
|
||||
EXPECT_EQ(Start::humanReadableSize(1000), Start::humanReadableSize(1001));
|
||||
}
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizeMB)
|
||||
{
|
||||
EXPECT_EQ("2.5 MB", Start::humanReadableSize(2.5e6));
|
||||
}
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizeGB)
|
||||
{
|
||||
EXPECT_EQ("3.7 GB", Start::humanReadableSize(3.7e9));
|
||||
}
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizeTB)
|
||||
{
|
||||
EXPECT_EQ("444.8 TB", Start::humanReadableSize(444.823e12));
|
||||
}
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizePB)
|
||||
{
|
||||
EXPECT_EQ("1.2 PB", Start::humanReadableSize(1.2e15));
|
||||
}
|
||||
|
||||
TEST_F(FileUtilitiesTest, humanReadableSizeEB)
|
||||
{
|
||||
EXPECT_EQ("7.3 EB", Start::humanReadableSize(7.3e18));
|
||||
}
|
||||
26
tests/src/Mod/Start/App/ThumbnailSource.cpp
Normal file
26
tests/src/Mod/Start/App/ThumbnailSource.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "src/App/InitApplication.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <Mod/Start/App/ThumbnailSource.h>
|
||||
|
||||
class ThumbnailSourceTest: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestSuite()
|
||||
{
|
||||
tests::initApplication();
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{}
|
||||
|
||||
void TearDown() override
|
||||
{}
|
||||
|
||||
|
||||
private:
|
||||
};
|
||||
13
tests/src/Mod/Start/CMakeLists.txt
Normal file
13
tests/src/Mod/Start/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
target_include_directories(Start_tests_run PUBLIC
|
||||
${Python3_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(Start_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
Start
|
||||
)
|
||||
Reference in New Issue
Block a user