MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / checkEntryByValue

Function checkEntryByValue

test/sockets/test_getprotobyname.c:15–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include <string.h>
14
15void checkEntryByValue(const char* name, int port, const char** aliasArray) {
16 struct protoent* entry;
17 char** aliases;
18
19 // Perform a protocol look up by name
20 entry = getprotobyname(name);
21 assert(entry != NULL);
22
23 // Check results
24 assert(strcmp(name, entry->p_name) == 0);
25 assert(port == entry->p_proto);
26
27 aliases = entry->p_aliases;
28 for (int i = 0; aliases[i] != NULL; i++) {
29 assert(strcmp(aliases[i], aliasArray[i]) == 0);
30 }
31
32 // Perform a protocol look up by number
33 entry = getprotobynumber(port);
34 assert(entry != NULL);
35
36 // Check results
37 assert(strcmp(name, entry->p_name) == 0);
38 assert(port == entry->p_proto);
39
40 aliases = entry->p_aliases;
41 for (int i = 0; aliases[i] != NULL; i++) {
42 assert(strcmp(aliases[i], aliasArray[i]) == 0);
43 }
44}
45
46void checkEntryDatabase() {
47 struct protoent* entry;

Callers 1

mainFunction · 0.85

Calls 4

getprotobynameFunction · 0.85
strcmpFunction · 0.85
getprotobynumberFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected