MCPcopy Create free account
hub / github.com/BinomialLLC/basis_universal / arith_test

Function arith_test

encoder/basisu_enc.cpp:4034–4354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4032 }
4033
4034 bool arith_test()
4035 {
4036 basist::arith_fastbits_f32::init();
4037
4038 fmt_printf("random bit test\n");
4039
4040 const uint32_t N = 1000;
4041
4042 // random bit test
4043 for (uint32_t i = 0; i < N; i++)
4044 {
4045 basist::arith::arith_enc enc;
4046 enc.init(4096);
4047
4048 {
4049 basisu::rand r;
4050 r.seed(i + 1);
4051 uint32_t num_vals = r.irand(1, 20000);
4052
4053 for (uint32_t j = 0; j < num_vals; j++)
4054 enc.put_bit(r.bit());
4055
4056 enc.flush();
4057 }
4058
4059 {
4060 basisu::rand r;
4061 r.seed(i + 1);
4062 uint32_t num_vals = r.irand(1, 20000);
4063
4064 basist::arith::arith_dec dec;
4065 dec.init(enc.get_data_buf().get_ptr(), enc.get_data_buf().size());
4066
4067 for (uint32_t j = 0; j < num_vals; j++)
4068 {
4069 uint32_t t = r.bit();
4070
4071 uint32_t a = dec.get_bit();
4072 if (t != a)
4073 {
4074 fmt_printf("error!");
4075 return false;
4076 }
4077 }
4078 }
4079 }
4080
4081 fmt_printf("Random bit test OK\n");
4082
4083 fmt_printf("random bits test\n");
4084
4085 // random bits test
4086 for (uint32_t i = 0; i < N; i++)
4087 {
4088 basist::arith::arith_enc enc;
4089 enc.init(4096);
4090
4091 {

Callers

nothing calls this directly

Calls 15

fmt_printfFunction · 0.85
put_bitMethod · 0.80
get_bitMethod · 0.80
decode_bitMethod · 0.80
decode_symMethod · 0.80
initFunction · 0.50
initMethod · 0.45
seedMethod · 0.45
irandMethod · 0.45
bitMethod · 0.45
flushMethod · 0.45
get_ptrMethod · 0.45

Tested by

no test coverage detected