body common control
{
  inputs => { "../../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
}

bundle common init
{
  vars:
    "expect"
      data => '{
        "pos_int": {
          "in": "12",
          "out": "12"
        },
        "pos_int_k": {
          "in": "21k",
          "out": "21000"
        },
        "neg_int": {
          "in": "-34",
          "out": "-34"
        },
        "neg_int_k": {
          "in": "-42k",
          "out": "-42000"
        },
        "pos_real": {
          "in": "56.789",
          "out": "56"
        },
        "pos_real_k": {
          "in": "65.987k",
          "out": "65987"
        },
        "neg_real": {
          "in": "-78.789",
          "out": "-78"
        },
        "neg_real_k": {
          "in": "-87.987k",
          "out": "-87987"
        },
      }';

    "cases" slist => getindices(@{expect});
    "all_ok_classes" slist => maplist("ok_${this}", @{cases});
}

bundle common test
{
  meta:
    "description" -> { "CFE-3616" }
      string => "Test whether the int() policy function properly returns integer from string";

  classes:
    "ok_${init.cases}"
      expression => strcmp(
        int("${init.expect[${init.cases}][in]}"),
        "${init.expect[${init.cases}][out]}"
      );
}

bundle agent check
{
  vars:
    "difference"
      slist => difference(@{init.all_ok_classes}, classesmatching("ok_.*"));

  classes:
    "ok" expression => strcmp("0", length(@{difference}));

  methods:
    "Pass/FAIL"
      usebundle => dcs_passif("ok", ${this.promise_filename}),
      inherit => "true";

  reports:
    !ok.DEBUG::
      "Ok classes not matching: ${with}" with => join(", ", @{difference});
}
