2021-01-04 09:47:30 +08:00
|
|
|
#include "tkc/fscript.h"
|
|
|
|
#include "tkc/object_default.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
TEST(FExr, cksum) {
|
|
|
|
value_t v;
|
2021-12-02 17:57:04 +08:00
|
|
|
tk_object_t* obj = object_default_create();
|
2021-01-04 09:47:30 +08:00
|
|
|
|
|
|
|
fscript_eval(obj, "cksum(\"1\")", &v);
|
2021-09-16 16:06:55 +08:00
|
|
|
ASSERT_EQ(value_uint32(&v), 65486u);
|
2021-01-04 09:47:30 +08:00
|
|
|
value_reset(&v);
|
2021-01-20 13:41:57 +08:00
|
|
|
|
2021-01-04 09:47:30 +08:00
|
|
|
fscript_eval(obj, "cksum(\"123\")", &v);
|
2021-09-16 16:06:55 +08:00
|
|
|
ASSERT_EQ(value_uint32(&v), 65385u);
|
2021-01-04 09:47:30 +08:00
|
|
|
value_reset(&v);
|
|
|
|
|
2021-12-02 17:57:04 +08:00
|
|
|
TK_OBJECT_UNREF(obj);
|
2021-01-04 09:47:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(FExr, crc16) {
|
|
|
|
value_t v;
|
2021-12-02 17:57:04 +08:00
|
|
|
tk_object_t* obj = object_default_create();
|
2021-01-04 09:47:30 +08:00
|
|
|
|
|
|
|
fscript_eval(obj, "crc16(\"1\")", &v);
|
2021-09-16 16:06:55 +08:00
|
|
|
ASSERT_EQ(value_uint32(&v), 53362u);
|
2021-01-04 09:47:30 +08:00
|
|
|
value_reset(&v);
|
2021-01-20 13:41:57 +08:00
|
|
|
|
2021-01-04 09:47:30 +08:00
|
|
|
fscript_eval(obj, "crc16(\"123\")", &v);
|
2021-09-16 16:06:55 +08:00
|
|
|
ASSERT_EQ(value_uint32(&v), 40116u);
|
2021-01-04 09:47:30 +08:00
|
|
|
value_reset(&v);
|
|
|
|
|
2021-12-02 17:57:04 +08:00
|
|
|
TK_OBJECT_UNREF(obj);
|
2021-01-04 09:47:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(FExr, crc32) {
|
|
|
|
value_t v;
|
2021-12-02 17:57:04 +08:00
|
|
|
tk_object_t* obj = object_default_create();
|
2021-01-04 09:47:30 +08:00
|
|
|
|
|
|
|
fscript_eval(obj, "crc32(\"1\")", &v);
|
2021-09-16 16:06:55 +08:00
|
|
|
ASSERT_EQ(value_uint32(&v), 2212294583u);
|
2021-01-04 09:47:30 +08:00
|
|
|
value_reset(&v);
|
2021-01-20 13:41:57 +08:00
|
|
|
|
2021-01-04 09:47:30 +08:00
|
|
|
fscript_eval(obj, "crc32(\"123\")", &v);
|
2021-09-16 16:06:55 +08:00
|
|
|
ASSERT_EQ(value_uint32(&v), 2286445522u);
|
2021-01-04 09:47:30 +08:00
|
|
|
value_reset(&v);
|
|
|
|
|
2021-12-02 17:57:04 +08:00
|
|
|
TK_OBJECT_UNREF(obj);
|
2021-01-04 09:47:30 +08:00
|
|
|
}
|