File: checkimplementation.cpp

package info (click to toggle)
simdjson 4.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,936 kB
  • sloc: cpp: 171,612; ansic: 19,122; sh: 1,126; python: 842; makefile: 47; ruby: 25; javascript: 13
file content (23 lines) | stat: -rw-r--r-- 1,078 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "simdjson.h"
#include <iostream>
#include <cstring>

int main(int argc, const char *argv[]) {
  std::cout << "simdjson v" << SIMDJSON_VERSION << " is running the " << simdjson::get_active_implementation()->name() << " implementation." << std::endl;
  const char *expected_implementation = nullptr;
  if (argc > 1) {
    expected_implementation = argv[1];
  } else {
    expected_implementation = getenv("SIMDJSON_FORCE_IMPLEMENTATION");
    if (!expected_implementation) {
      std::cout << "No expected implementation argument and SIMDJSON_FORCE_IMPLEMENTATION is not set, success by default!" << std::endl;
      return EXIT_SUCCESS;
    }
    std::cout << "No expected implementation argument, but SIMDJSON_FORCE_IMPLEMENTATION is set to " << expected_implementation << ", so we'll check for that." << std::endl;
  }
  if (strcmp(expected_implementation, simdjson::get_active_implementation()->name().c_str())) {
    std::cerr << "Wrong implementation! Expected " << expected_implementation << "." << std::endl;
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}