File: test-types.c

package info (click to toggle)
bar 1.11.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 928 kB
  • sloc: ansic: 4,381; sh: 3,334; makefile: 264
file content (73 lines) | stat: -rw-r--r-- 925 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "config.h"

#include "headers.h"
#include "types.h"

void test_u8(void)
{
	uint8 u8 = 0;
	uint8 u8_old = 0;
	unsigned int c = 0;

	u8 = 1;
	for (c = 0; u8 != u8_old; c++) {
		u8_old = u8;
		u8 <<= 1;
		u8 |= 1;
	}
	assert(c == 8);
}

void test_u16(void)
{
	uint16 u16 = 0;
	uint16 u16_old = 0;
	unsigned int c = 0;

	u16 = 1;
	for (c = 0; u16 != u16_old; c++) {
		u16_old = u16;
		u16 <<= 1;
		u16 |= 1;
	}
	assert(c == 16);
}

void test_u32(void)
{
	uint32 u32 = 0;
	uint32 u32_old = 0;
	unsigned int c = 0;

	u32 = 1;
	for (c = 0; u32 != u32_old; c++) {
		u32_old = u32;
		u32 <<= 1;
		u32 |= 1;
	}
	assert(c == 32);
}

void test_u64(void)
{
	uint64 u64 = 0;
	uint64 u64_old = 0;
	unsigned int c = 0;

	u64 = 1;
	for (c = 0; u64 != u64_old; c++) {
		u64_old = u64;
		u64 <<= 1;
		u64 |= 1;
	}
	assert(c == 64);
}

int main(int argc, char* argv[])
{
	test_u8();
	test_u16();
	test_u32();
	test_u64();
	return(0);
}