test-utils.cpp 542 B

123456789101112131415161718192021222324252627
  1. #include "test-utils.h"
  2. #include <arpa/inet.h>
  3. using namespace limbo;
  4. using namespace limbo::ip;
  5. IPv4Address make_address(const char *addr) {
  6. in_addr value;
  7. auto r = inet_pton(AF_INET, addr, &value);
  8. if (!r) {
  9. return IPv4Address();
  10. } else {
  11. return IPv4Address::from_network(value.s_addr);
  12. }
  13. }
  14. bool operator==(const Chunk &a, const Chunk &b) {
  15. if (a.size() == b.size()) {
  16. if (a.data() == b.data()) {
  17. return true;
  18. } else {
  19. return memcmp(a.data(), b.data(), a.size()) == 0;
  20. }
  21. }
  22. return false;
  23. }