MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / setup_sim_test_repo

Function setup_sim_test_repo

tests/test_simhash.c:845–907  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

843static char g_sim_tmpdir[512];
844
845static int setup_sim_test_repo(void) {
846 snprintf(g_sim_tmpdir, sizeof(g_sim_tmpdir), "/tmp/cbm_sim_test_XXXXXX");
847 if (!cbm_mkdtemp(g_sim_tmpdir)) {
848 return -1;
849 }
850
851 /* Near-clone: ValidateUser and ValidateOrder have same structure, different names.
852 * Must be large enough (>= 30 leaf tokens, >= 32 unique structural trigrams). */
853 th_write_file(
854 TH_PATH(g_sim_tmpdir, "pkg/validation/user_validator.go"),
855 "package validation\n"
856 "import \"errors\"\n"
857 "import \"strings\"\n"
858 "func ValidateUser(u User) error {\n"
859 " if u.Name == \"\" { return errors.New(\"name required\") }\n"
860 " if len(u.Name) > 100 { return errors.New(\"name too long\") }\n"
861 " if u.Age < 0 { return errors.New(\"invalid age\") }\n"
862 " if u.Age > 200 { return errors.New(\"age too high\") }\n"
863 " if u.Email == \"\" { return errors.New(\"email required\") }\n"
864 " if !strings.Contains(u.Email, \"@\") { return errors.New(\"invalid email\") }\n"
865 " if u.Phone == \"\" { return errors.New(\"phone required\") }\n"
866 " if len(u.Phone) < 7 { return errors.New(\"phone too short\") }\n"
867 " if u.Country == \"\" { return errors.New(\"country required\") }\n"
868 " for _, c := range u.Tags {\n"
869 " if c == \"\" { return errors.New(\"empty tag\") }\n"
870 " }\n"
871 " return nil\n"
872 "}\n");
873
874 th_write_file(
875 TH_PATH(g_sim_tmpdir, "pkg/validation/order_validator.go"),
876 "package validation\n"
877 "import \"errors\"\n"
878 "import \"strings\"\n"
879 "func ValidateOrder(o Order) error {\n"
880 " if o.Title == \"\" { return errors.New(\"title required\") }\n"
881 " if len(o.Title) > 100 { return errors.New(\"title too long\") }\n"
882 " if o.Amount < 0 { return errors.New(\"invalid amount\") }\n"
883 " if o.Amount > 200 { return errors.New(\"amount too high\") }\n"
884 " if o.Status == \"\" { return errors.New(\"status required\") }\n"
885 " if !strings.Contains(o.Status, \"@\") { return errors.New(\"invalid status\") }\n"
886 " if o.Region == \"\" { return errors.New(\"region required\") }\n"
887 " if len(o.Region) < 7 { return errors.New(\"region too short\") }\n"
888 " if o.Vendor == \"\" { return errors.New(\"vendor required\") }\n"
889 " for _, c := range o.Items {\n"
890 " if c == \"\" { return errors.New(\"empty item\") }\n"
891 " }\n"
892 " return nil\n"
893 "}\n");
894
895 /* Completely different function — also large enough for fingerprinting */
896 th_write_file(TH_PATH(g_sim_tmpdir, "pkg/handler/user_handler.go"), GO_HANDLE_REQUEST_SRC);
897
898 /* Tiny function — should be skipped */
899 th_write_file(TH_PATH(g_sim_tmpdir, "pkg/util/tiny_helper.go"), "package util\n"
900 "\n"
901 "func Max(a, b int) int {\n"
902 " if a > b { return a }\n"

Callers 1

test_simhash.cFile · 0.85

Calls 2

cbm_mkdtempFunction · 0.85
th_write_fileFunction · 0.85

Tested by

no test coverage detected