json-c: add test (#12168)

This commit is contained in:
Zhiming Wang 2017-04-07 00:20:51 -04:00 committed by ilovezfs
parent 2de7394271
commit 895222365d

View file

@ -31,4 +31,21 @@ class JsonC < Formula
ENV.deparallelize
system "make", "install"
end
test do
(testpath/"test.c").write <<-'EOS'.undent
#include <stdio.h>
#include <json-c/json.h>
int main() {
json_object *obj = json_object_new_object();
json_object *value = json_object_new_string("value");
json_object_object_add(obj, "key", value);
printf("%s\n", json_object_to_json_string(obj));
return 0;
}
EOS
system ENV.cc, "-I#{include}", "-L#{lib}", "-ljson-c", "test.c", "-o", "test"
assert_equal '{ "key": "value" }', shell_output("./test").chomp
end
end