2018-06-27 13:46:42 +08:00
|
|
|
|
#include "base/glyph_cache.h"
|
2018-06-10 08:24:42 +08:00
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
|
|
TEST(GlyphCache, basic) {
|
|
|
|
|
uint16_t i = 0;
|
|
|
|
|
uint16_t size = 10;
|
|
|
|
|
uint16_t nr = 10000;
|
|
|
|
|
glyph_cache_t cache;
|
|
|
|
|
glyph_t g;
|
2019-01-19 12:06:25 +08:00
|
|
|
|
glyph_cache_t* c = glyph_cache_init(&cache, 64, (tk_destroy_t)glyph_destroy);
|
2018-06-10 08:24:42 +08:00
|
|
|
|
|
2018-06-10 17:39:20 +08:00
|
|
|
|
for (i = 0; i < nr; i++) {
|
2018-06-10 08:24:42 +08:00
|
|
|
|
ASSERT_EQ(glyph_cache_lookup(c, i, size, &g) == RET_NOT_FOUND, true);
|
2018-12-27 17:15:22 +08:00
|
|
|
|
ASSERT_EQ(glyph_cache_add(c, i, size, glyph_clone(&g)) == RET_OK, true);
|
2018-06-10 08:24:42 +08:00
|
|
|
|
ASSERT_EQ(glyph_cache_lookup(c, i, size, &g) == RET_OK, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glyph_cache_deinit(c);
|
|
|
|
|
}
|