3366 | | uint8_t zz = 0; |

3367 | | uint8_t ii = 0; |

3368 | | int z; |

3369 | | for (i = 0; i < 256; i++) { |

3370 | | ii = (uint8_t)i; |

3371 | | test_eq(tor_memeq(&zz, &ii, 1), zz == ii); |

3372 | | } |

3373 | | |

3374 | | /* exhaustively white-box test tor_memcmp |

3375 | | * against each possible single-byte numeric difference |

3376 | | * some arithmetic bugs only appear with certain bit patterns */ |

3377 | | for (z = 0; z < 256; z++) { |

3378 | | for (i = 0; i < 256; i++) { |

3379 | | ii = (uint8_t)i; |

3380 | | zz = (uint8_t)z; |

3381 | | test_eq(tor_memcmp(&zz, &ii, 1) > 0 ? GT : EQ, zz > ii ? GT : EQ); |

3382 | | test_eq(tor_memcmp(&ii, &zz, 1) < 0 ? LT : EQ, ii < zz ? LT : EQ); |

| 3369 | uint8_t zz = 0; |

| 3370 | uint8_t ii = 0; |

| 3371 | int z; |

| 3372 | |

| 3373 | /* exhaustively test tor_memeq and tor_memcmp |

| 3374 | * against each possible single-byte numeric difference |

| 3375 | * some arithmetic bugs only appear with certain bit patterns */ |

| 3376 | for (z = 0; z < 256; z++) { |

| 3377 | for (i = 0; i < 256; i++) { |

| 3378 | ii = (uint8_t)i; |

| 3379 | zz = (uint8_t)z; |

| 3380 | test_eq(tor_memeq(&zz, &ii, 1), zz == ii); |

| 3381 | test_eq(tor_memcmp(&zz, &ii, 1) > 0 ? GT : EQ, zz > ii ? GT : EQ); |

| 3382 | test_eq(tor_memcmp(&ii, &zz, 1) < 0 ? LT : EQ, ii < zz ? LT : EQ); |

| 3383 | } |