test: Update 5 files
This commit is contained in:
33
tests/cprdemo/src/main.cpp
Normal file
33
tests/cprdemo/src/main.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <cpr/cpr.h>
|
||||
|
||||
#include "version.hpp"
|
||||
#include "assert.hpp"
|
||||
|
||||
void crashy() {
|
||||
ASSERT(false, "SUCCESS!");
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::cout << "cprdemo version: " << cprdemo::VERSION << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Retrieving IP address using CPR..." << std::endl;
|
||||
|
||||
// Use CPR to make HTTP GET request
|
||||
cpr::Response r = cpr::Get(cpr::Url{"https://ipinfo.io/ip"});
|
||||
|
||||
ASSERT(r.status_code == 200, "Failed to get IP");
|
||||
|
||||
nlohmann::json j;
|
||||
j["ip"] = r.text;
|
||||
j["status"] = r.status_code;
|
||||
|
||||
std::cout << j.dump(4) << std::endl;
|
||||
|
||||
std::cout << "Done" << std::endl;
|
||||
|
||||
crashy();
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user