Audacity 3.2.0
Classes | Namespaces | Functions
GraphicsDataCacheTests.cpp File Reference
#include <catch2/catch.hpp>
#include <string>
#include <string_view>
#include <type_traits>
#include "GraphicsDataCache.h"
#include "ZoomInfo.h"
Include dependency graph for GraphicsDataCacheTests.cpp:

Go to the source code of this file.

Classes

struct  anonymous_namespace{GraphicsDataCacheTests.cpp}::CacheElement
 

Namespaces

namespace  anonymous_namespace{GraphicsDataCacheTests.cpp}
 

Functions

void anonymous_namespace{GraphicsDataCacheTests.cpp}::CheckCacheElementLookup (GraphicsDataCache< CacheElement > &cache, const ZoomInfo &zoomInfo, double t0, double t1, size_t count)
 
 TEST_CASE ("graphics-data-cache", "")
 

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "graphics-data-cache"  ,
""   
)

Definition at line 88 of file GraphicsDataCacheTests.cpp.

89{
91
92 GraphicsDataCache<CacheElement> cache(44100, [](){ return std::make_unique<CacheElement>(); });
93
94 REQUIRE(cache.PerformLookup(info, 0, 0).empty());
95 REQUIRE(!cache.PerformLookup(info, 0, 1).empty());
96
97 REQUIRE(cache.PerformLookup(info, 0, 1).first->LastCacheAccess == 2);
98
99 CheckCacheElementLookup(cache, info, 0.0, 1.0, 1);
100 CheckCacheElementLookup(cache, info, 0.0, 2.0, 1);
101 CheckCacheElementLookup(cache, info, 0.0, 3.0, 2);
102 CheckCacheElementLookup(cache, info, 0.0, 4.0, 2);
103 CheckCacheElementLookup(cache, info, 0.0, 5.0, 2);
104 CheckCacheElementLookup(cache, info, 0.0, 6.0, 3);
105
106 CheckCacheElementLookup(cache, info, 0.5, 1.0, 1);
107
108 for (int i = 0; i < 128; ++i)
109 {
110 const double t0 = i;
111 const double t1 = t0 + 2;
112
113 const int64_t itemsCount = 1 +
114 info.TimeToPosition(t1) / GraphicsDataCacheBase::CacheElementWidth -
115 info.TimeToPosition(t0) / GraphicsDataCacheBase::CacheElementWidth;
116
117 CheckCacheElementLookup(cache, info, t0, t1, itemsCount);
118 }
119}
static constexpr uint32_t CacheElementWidth
static double GetDefaultZoom()
Definition: ZoomInfo.h:116
void CheckCacheElementLookup(GraphicsDataCache< CacheElement > &cache, const ZoomInfo &zoomInfo, double t0, double t1, size_t count)

References GraphicsDataCacheBase::CacheElementWidth, anonymous_namespace{GraphicsDataCacheTests.cpp}::CheckCacheElementLookup(), ZoomInfo::GetDefaultZoom(), and ZoomInfo::TimeToPosition().

Here is the call graph for this function: