#module_parameters(RUN_TESTS := false);

// Can be passed directly to using,map
remap_snake_to_pascal :: (names: []string) {
   for names {
      names[it_index] = snake_to_pascal(it);
   }
}

snake_to_pascal :: (name: string) -> string {
   basic :: #import "Basic"; // @future
   b: basic.String_Builder;

   upper := true;
   for i: 0..name.count - 1 {
      c := name[i];
      if c == #char "_" {
         upper = true;
         continue;
      }

      if upper {
         basic.append(*b, basic.to_upper(c));
         upper = false;
      } else {
         basic.append(*b, c);
      }
   }

   return basic.builder_to_string(*b);
}

#load "macros.jai";
#load "type_info.jai";


#scope_module;

mem :: #import "jc/memory";


// ----------------------------------------------------------
// TESTS
// ----------------------------------------------------------

#if RUN_TESTS {
   test :: #import "jc/test";

   #run test.run("snake_to_pascal", t => {
      test.expect(t, snake_to_pascal("some_name")  == "SomeName");
      test.expect(t, snake_to_pascal("_some_name") == "SomeName");
      test.expect(t, snake_to_pascal("some__name") == "SomeName");
      test.expect(t, snake_to_pascal("some_name_") == "SomeName");
      test.expect(t, snake_to_pascal("X_Y_Z")      == "XYZ");
      test.expect(t, snake_to_pascal("XY_Z")       == "XYZ");
   });
}
