You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
500 B
C
26 lines
500 B
C
#include "parse.h"
|
|
|
|
uint16_t prs_u16_big(struct bytestream* bs) {
|
|
uint16_t x = bs_get(bs) << 8;
|
|
return x | bs_get(bs);
|
|
}
|
|
|
|
#ifdef UNITTEST
|
|
#include <assert.h>
|
|
|
|
#undef UNITTEST
|
|
#include "buffer/bs_get.c"
|
|
#include "buffer/bs_err.c"
|
|
|
|
// mock this
|
|
ssize_t buffer_getc(buffer* b,char* c) { return 0; }
|
|
|
|
int main() {
|
|
struct bytestream bs = BS_FROM_MEMBUF("\x12\x34",2);
|
|
assert(prs_u16_big(&bs) == 0x1234);
|
|
assert(bs_err(&bs) == 0);
|
|
assert(prs_u16_big(&bs) == 0);
|
|
assert(bs_err(&bs));
|
|
}
|
|
#endif
|