| ... | ... | @@ -782,7 +782,26 @@ fn expand_variables_cmake( |
| 782 | 782 | return result.toOwnedSlice(); |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | | fn testReplaceVariables( |
| 785 | fn testReplaceVariablesAutoconfAt( |
| 786 | allocator: Allocator, |
| 787 | contents: []const u8, |
| 788 | expected: []const u8, |
| 789 | values: std.StringArrayHashMap(Value), |
| 790 | ) !void { |
| 791 | var output = std.ArrayList(u8).init(allocator); |
| 792 | defer output.deinit(); |
| 793 | |
| 794 | const used = try allocator.alloc(bool, values.count()); |
| 795 | for (used) |*u| u.* = false; |
| 796 | defer allocator.free(used); |
| 797 | |
| 798 | try expand_variables_autoconf_at(&output, contents, values, used); |
| 799 | |
| 800 | for (used) |u| if (!u) return error.UnusedValue; |
| 801 | try std.testing.expectEqualStrings(expected, output.items); |
| 802 | } |
| 803 | |
| 804 | fn testReplaceVariablesCMake( |
| 786 | 805 | allocator: Allocator, |
| 787 | 806 | contents: []const u8, |
| 788 | 807 | expected: []const u8, |
| ... | ... | @@ -794,6 +813,118 @@ fn testReplaceVariables( |
| 794 | 813 | try std.testing.expectEqualStrings(expected, actual); |
| 795 | 814 | } |
| 796 | 815 | |
| 816 | test "expand_variables_autoconf_at simple cases" { |
| 817 | const allocator = std.testing.allocator; |
| 818 | var values = std.StringArrayHashMap(Value).init(allocator); |
| 819 | defer values.deinit(); |
| 820 | |
| 821 | // empty strings are preserved |
| 822 | try testReplaceVariablesAutoconfAt(allocator, "", "", values); |
| 823 | |
| 824 | // line with misc content is preserved |
| 825 | try testReplaceVariablesAutoconfAt(allocator, "no substitution", "no substitution", values); |
| 826 | |
| 827 | // empty @ sigils are preserved |
| 828 | try testReplaceVariablesAutoconfAt(allocator, "@", "@", values); |
| 829 | try testReplaceVariablesAutoconfAt(allocator, "@@", "@@", values); |
| 830 | try testReplaceVariablesAutoconfAt(allocator, "@@@", "@@@", values); |
| 831 | try testReplaceVariablesAutoconfAt(allocator, "@@@@", "@@@@", values); |
| 832 | |
| 833 | // simple substitution |
| 834 | try values.putNoClobber("undef", .undef); |
| 835 | try testReplaceVariablesAutoconfAt(allocator, "@undef@", "", values); |
| 836 | values.clearRetainingCapacity(); |
| 837 | |
| 838 | try values.putNoClobber("defined", .defined); |
| 839 | try testReplaceVariablesAutoconfAt(allocator, "@defined@", "", values); |
| 840 | values.clearRetainingCapacity(); |
| 841 | |
| 842 | try values.putNoClobber("true", Value{ .boolean = true }); |
| 843 | try testReplaceVariablesAutoconfAt(allocator, "@true@", "1", values); |
| 844 | values.clearRetainingCapacity(); |
| 845 | |
| 846 | try values.putNoClobber("false", Value{ .boolean = false }); |
| 847 | try testReplaceVariablesAutoconfAt(allocator, "@false@", "0", values); |
| 848 | values.clearRetainingCapacity(); |
| 849 | |
| 850 | try values.putNoClobber("int", Value{ .int = 42 }); |
| 851 | try testReplaceVariablesAutoconfAt(allocator, "@int@", "42", values); |
| 852 | values.clearRetainingCapacity(); |
| 853 | |
| 854 | try values.putNoClobber("ident", Value{ .string = "value" }); |
| 855 | try testReplaceVariablesAutoconfAt(allocator, "@ident@", "value", values); |
| 856 | values.clearRetainingCapacity(); |
| 857 | |
| 858 | try values.putNoClobber("string", Value{ .string = "text" }); |
| 859 | try testReplaceVariablesAutoconfAt(allocator, "@string@", "text", values); |
| 860 | values.clearRetainingCapacity(); |
| 861 | |
| 862 | // double packed substitution |
| 863 | try values.putNoClobber("string", Value{ .string = "text" }); |
| 864 | try testReplaceVariablesAutoconfAt(allocator, "@string@@string@", "texttext", values); |
| 865 | values.clearRetainingCapacity(); |
| 866 | |
| 867 | // triple packed substitution |
| 868 | try values.putNoClobber("int", Value{ .int = 42 }); |
| 869 | try values.putNoClobber("string", Value{ .string = "text" }); |
| 870 | try testReplaceVariablesAutoconfAt(allocator, "@string@@int@@string@", "text42text", values); |
| 871 | values.clearRetainingCapacity(); |
| 872 | |
| 873 | // double separated substitution |
| 874 | try values.putNoClobber("int", Value{ .int = 42 }); |
| 875 | try testReplaceVariablesAutoconfAt(allocator, "@int@.@int@", "42.42", values); |
| 876 | values.clearRetainingCapacity(); |
| 877 | |
| 878 | // triple separated substitution |
| 879 | try values.putNoClobber("true", Value{ .boolean = true }); |
| 880 | try values.putNoClobber("int", Value{ .int = 42 }); |
| 881 | try testReplaceVariablesAutoconfAt(allocator, "@int@.@true@.@int@", "42.1.42", values); |
| 882 | values.clearRetainingCapacity(); |
| 883 | |
| 884 | // misc prefix is preserved |
| 885 | try values.putNoClobber("false", Value{ .boolean = false }); |
| 886 | try testReplaceVariablesAutoconfAt(allocator, "false is @false@", "false is 0", values); |
| 887 | values.clearRetainingCapacity(); |
| 888 | |
| 889 | // misc suffix is preserved |
| 890 | try values.putNoClobber("true", Value{ .boolean = true }); |
| 891 | try testReplaceVariablesAutoconfAt(allocator, "@true@ is true", "1 is true", values); |
| 892 | values.clearRetainingCapacity(); |
| 893 | |
| 894 | // surrounding content is preserved |
| 895 | try values.putNoClobber("int", Value{ .int = 42 }); |
| 896 | try testReplaceVariablesAutoconfAt(allocator, "what is 6*7? @int@!", "what is 6*7? 42!", values); |
| 897 | values.clearRetainingCapacity(); |
| 898 | |
| 899 | // incomplete key is preserved |
| 900 | try testReplaceVariablesAutoconfAt(allocator, "@undef", "@undef", values); |
| 901 | |
| 902 | // unknown key leads to an error |
| 903 | try std.testing.expectError(error.MissingValue, testReplaceVariablesAutoconfAt(allocator, "@bad@", "", values)); |
| 904 | |
| 905 | // unused key leads to an error |
| 906 | try values.putNoClobber("int", Value{ .int = 42 }); |
| 907 | try values.putNoClobber("false", Value{ .boolean = false }); |
| 908 | try std.testing.expectError(error.UnusedValue, testReplaceVariablesAutoconfAt(allocator, "@int", "", values)); |
| 909 | values.clearRetainingCapacity(); |
| 910 | } |
| 911 | |
| 912 | test "expand_variables_autoconf_at edge cases" { |
| 913 | const allocator = std.testing.allocator; |
| 914 | var values = std.StringArrayHashMap(Value).init(allocator); |
| 915 | defer values.deinit(); |
| 916 | |
| 917 | // @-vars resolved only when they wrap valid characters, otherwise considered literals |
| 918 | try values.putNoClobber("string", Value{ .string = "text" }); |
| 919 | try testReplaceVariablesAutoconfAt(allocator, "@@string@@", "@text@", values); |
| 920 | values.clearRetainingCapacity(); |
| 921 | |
| 922 | // expanded variables are considered strings after expansion |
| 923 | try values.putNoClobber("string_at", Value{ .string = "@string@" }); |
| 924 | try testReplaceVariablesAutoconfAt(allocator, "@string_at@", "@string@", values); |
| 925 | values.clearRetainingCapacity(); |
| 926 | } |
| 927 | |
| 797 | 928 | test "expand_variables_cmake simple cases" { |
| 798 | 929 | const allocator = std.testing.allocator; |
| 799 | 930 | var values = std.StringArrayHashMap(Value).init(allocator); |
| ... | ... | @@ -808,78 +939,78 @@ test "expand_variables_cmake simple cases" { |
| 808 | 939 | try values.putNoClobber("string", Value{ .string = "text" }); |
| 809 | 940 | |
| 810 | 941 | // empty strings are preserved |
| 811 | | try testReplaceVariables(allocator, "", "", values); |
| 942 | try testReplaceVariablesCMake(allocator, "", "", values); |
| 812 | 943 | |
| 813 | 944 | // line with misc content is preserved |
| 814 | | try testReplaceVariables(allocator, "no substitution", "no substitution", values); |
| 945 | try testReplaceVariablesCMake(allocator, "no substitution", "no substitution", values); |
| 815 | 946 | |
| 816 | 947 | // empty ${} wrapper leads to an error |
| 817 | | try std.testing.expectError(error.MissingKey, testReplaceVariables(allocator, "${}", "", values)); |
| 948 | try std.testing.expectError(error.MissingKey, testReplaceVariablesCMake(allocator, "${}", "", values)); |
| 818 | 949 | |
| 819 | 950 | // empty @ sigils are preserved |
| 820 | | try testReplaceVariables(allocator, "@", "@", values); |
| 821 | | try testReplaceVariables(allocator, "@@", "@@", values); |
| 822 | | try testReplaceVariables(allocator, "@@@", "@@@", values); |
| 823 | | try testReplaceVariables(allocator, "@@@@", "@@@@", values); |
| 951 | try testReplaceVariablesCMake(allocator, "@", "@", values); |
| 952 | try testReplaceVariablesCMake(allocator, "@@", "@@", values); |
| 953 | try testReplaceVariablesCMake(allocator, "@@@", "@@@", values); |
| 954 | try testReplaceVariablesCMake(allocator, "@@@@", "@@@@", values); |
| 824 | 955 | |
| 825 | 956 | // simple substitution |
| 826 | | try testReplaceVariables(allocator, "@undef@", "", values); |
| 827 | | try testReplaceVariables(allocator, "${undef}", "", values); |
| 828 | | try testReplaceVariables(allocator, "@defined@", "", values); |
| 829 | | try testReplaceVariables(allocator, "${defined}", "", values); |
| 830 | | try testReplaceVariables(allocator, "@true@", "1", values); |
| 831 | | try testReplaceVariables(allocator, "${true}", "1", values); |
| 832 | | try testReplaceVariables(allocator, "@false@", "0", values); |
| 833 | | try testReplaceVariables(allocator, "${false}", "0", values); |
| 834 | | try testReplaceVariables(allocator, "@int@", "42", values); |
| 835 | | try testReplaceVariables(allocator, "${int}", "42", values); |
| 836 | | try testReplaceVariables(allocator, "@ident@", "value", values); |
| 837 | | try testReplaceVariables(allocator, "${ident}", "value", values); |
| 838 | | try testReplaceVariables(allocator, "@string@", "text", values); |
| 839 | | try testReplaceVariables(allocator, "${string}", "text", values); |
| 957 | try testReplaceVariablesCMake(allocator, "@undef@", "", values); |
| 958 | try testReplaceVariablesCMake(allocator, "${undef}", "", values); |
| 959 | try testReplaceVariablesCMake(allocator, "@defined@", "", values); |
| 960 | try testReplaceVariablesCMake(allocator, "${defined}", "", values); |
| 961 | try testReplaceVariablesCMake(allocator, "@true@", "1", values); |
| 962 | try testReplaceVariablesCMake(allocator, "${true}", "1", values); |
| 963 | try testReplaceVariablesCMake(allocator, "@false@", "0", values); |
| 964 | try testReplaceVariablesCMake(allocator, "${false}", "0", values); |
| 965 | try testReplaceVariablesCMake(allocator, "@int@", "42", values); |
| 966 | try testReplaceVariablesCMake(allocator, "${int}", "42", values); |
| 967 | try testReplaceVariablesCMake(allocator, "@ident@", "value", values); |
| 968 | try testReplaceVariablesCMake(allocator, "${ident}", "value", values); |
| 969 | try testReplaceVariablesCMake(allocator, "@string@", "text", values); |
| 970 | try testReplaceVariablesCMake(allocator, "${string}", "text", values); |
| 840 | 971 | |
| 841 | 972 | // double packed substitution |
| 842 | | try testReplaceVariables(allocator, "@string@@string@", "texttext", values); |
| 843 | | try testReplaceVariables(allocator, "${string}${string}", "texttext", values); |
| 973 | try testReplaceVariablesCMake(allocator, "@string@@string@", "texttext", values); |
| 974 | try testReplaceVariablesCMake(allocator, "${string}${string}", "texttext", values); |
| 844 | 975 | |
| 845 | 976 | // triple packed substitution |
| 846 | | try testReplaceVariables(allocator, "@string@@int@@string@", "text42text", values); |
| 847 | | try testReplaceVariables(allocator, "@string@${int}@string@", "text42text", values); |
| 848 | | try testReplaceVariables(allocator, "${string}@int@${string}", "text42text", values); |
| 849 | | try testReplaceVariables(allocator, "${string}${int}${string}", "text42text", values); |
| 977 | try testReplaceVariablesCMake(allocator, "@string@@int@@string@", "text42text", values); |
| 978 | try testReplaceVariablesCMake(allocator, "@string@${int}@string@", "text42text", values); |
| 979 | try testReplaceVariablesCMake(allocator, "${string}@int@${string}", "text42text", values); |
| 980 | try testReplaceVariablesCMake(allocator, "${string}${int}${string}", "text42text", values); |
| 850 | 981 | |
| 851 | 982 | // double separated substitution |
| 852 | | try testReplaceVariables(allocator, "@int@.@int@", "42.42", values); |
| 853 | | try testReplaceVariables(allocator, "${int}.${int}", "42.42", values); |
| 983 | try testReplaceVariablesCMake(allocator, "@int@.@int@", "42.42", values); |
| 984 | try testReplaceVariablesCMake(allocator, "${int}.${int}", "42.42", values); |
| 854 | 985 | |
| 855 | 986 | // triple separated substitution |
| 856 | | try testReplaceVariables(allocator, "@int@.@true@.@int@", "42.1.42", values); |
| 857 | | try testReplaceVariables(allocator, "@int@.${true}.@int@", "42.1.42", values); |
| 858 | | try testReplaceVariables(allocator, "${int}.@true@.${int}", "42.1.42", values); |
| 859 | | try testReplaceVariables(allocator, "${int}.${true}.${int}", "42.1.42", values); |
| 987 | try testReplaceVariablesCMake(allocator, "@int@.@true@.@int@", "42.1.42", values); |
| 988 | try testReplaceVariablesCMake(allocator, "@int@.${true}.@int@", "42.1.42", values); |
| 989 | try testReplaceVariablesCMake(allocator, "${int}.@true@.${int}", "42.1.42", values); |
| 990 | try testReplaceVariablesCMake(allocator, "${int}.${true}.${int}", "42.1.42", values); |
| 860 | 991 | |
| 861 | 992 | // misc prefix is preserved |
| 862 | | try testReplaceVariables(allocator, "false is @false@", "false is 0", values); |
| 863 | | try testReplaceVariables(allocator, "false is ${false}", "false is 0", values); |
| 993 | try testReplaceVariablesCMake(allocator, "false is @false@", "false is 0", values); |
| 994 | try testReplaceVariablesCMake(allocator, "false is ${false}", "false is 0", values); |
| 864 | 995 | |
| 865 | 996 | // misc suffix is preserved |
| 866 | | try testReplaceVariables(allocator, "@true@ is true", "1 is true", values); |
| 867 | | try testReplaceVariables(allocator, "${true} is true", "1 is true", values); |
| 997 | try testReplaceVariablesCMake(allocator, "@true@ is true", "1 is true", values); |
| 998 | try testReplaceVariablesCMake(allocator, "${true} is true", "1 is true", values); |
| 868 | 999 | |
| 869 | 1000 | // surrounding content is preserved |
| 870 | | try testReplaceVariables(allocator, "what is 6*7? @int@!", "what is 6*7? 42!", values); |
| 871 | | try testReplaceVariables(allocator, "what is 6*7? ${int}!", "what is 6*7? 42!", values); |
| 1001 | try testReplaceVariablesCMake(allocator, "what is 6*7? @int@!", "what is 6*7? 42!", values); |
| 1002 | try testReplaceVariablesCMake(allocator, "what is 6*7? ${int}!", "what is 6*7? 42!", values); |
| 872 | 1003 | |
| 873 | 1004 | // incomplete key is preserved |
| 874 | | try testReplaceVariables(allocator, "@undef", "@undef", values); |
| 875 | | try testReplaceVariables(allocator, "${undef", "${undef", values); |
| 876 | | try testReplaceVariables(allocator, "{undef}", "{undef}", values); |
| 877 | | try testReplaceVariables(allocator, "undef@", "undef@", values); |
| 878 | | try testReplaceVariables(allocator, "undef}", "undef}", values); |
| 1005 | try testReplaceVariablesCMake(allocator, "@undef", "@undef", values); |
| 1006 | try testReplaceVariablesCMake(allocator, "${undef", "${undef", values); |
| 1007 | try testReplaceVariablesCMake(allocator, "{undef}", "{undef}", values); |
| 1008 | try testReplaceVariablesCMake(allocator, "undef@", "undef@", values); |
| 1009 | try testReplaceVariablesCMake(allocator, "undef}", "undef}", values); |
| 879 | 1010 | |
| 880 | 1011 | // unknown key leads to an error |
| 881 | | try std.testing.expectError(error.MissingValue, testReplaceVariables(allocator, "@bad@", "", values)); |
| 882 | | try std.testing.expectError(error.MissingValue, testReplaceVariables(allocator, "${bad}", "", values)); |
| 1012 | try std.testing.expectError(error.MissingValue, testReplaceVariablesCMake(allocator, "@bad@", "", values)); |
| 1013 | try std.testing.expectError(error.MissingValue, testReplaceVariablesCMake(allocator, "${bad}", "", values)); |
| 883 | 1014 | } |
| 884 | 1015 | |
| 885 | 1016 | test "expand_variables_cmake edge cases" { |
| ... | ... | @@ -906,41 +1037,41 @@ test "expand_variables_cmake edge cases" { |
| 906 | 1037 | try values.putNoClobber("nest_proxy", Value{ .string = "nest_underscore_proxy" }); |
| 907 | 1038 | |
| 908 | 1039 | // @-vars resolved only when they wrap valid characters, otherwise considered literals |
| 909 | | try testReplaceVariables(allocator, "@@string@@", "@text@", values); |
| 910 | | try testReplaceVariables(allocator, "@${string}@", "@text@", values); |
| 1040 | try testReplaceVariablesCMake(allocator, "@@string@@", "@text@", values); |
| 1041 | try testReplaceVariablesCMake(allocator, "@${string}@", "@text@", values); |
| 911 | 1042 | |
| 912 | 1043 | // @-vars are resolved inside ${}-vars |
| 913 | | try testReplaceVariables(allocator, "${@string_proxy@}", "text", values); |
| 1044 | try testReplaceVariablesCMake(allocator, "${@string_proxy@}", "text", values); |
| 914 | 1045 | |
| 915 | 1046 | // expanded variables are considered strings after expansion |
| 916 | | try testReplaceVariables(allocator, "@string_at@", "@string@", values); |
| 917 | | try testReplaceVariables(allocator, "${string_at}", "@string@", values); |
| 918 | | try testReplaceVariables(allocator, "$@string_curly@", "${string}", values); |
| 919 | | try testReplaceVariables(allocator, "$${string_curly}", "${string}", values); |
| 920 | | try testReplaceVariables(allocator, "${string_var}", "${string}", values); |
| 921 | | try testReplaceVariables(allocator, "@string_var@", "${string}", values); |
| 922 | | try testReplaceVariables(allocator, "${dollar}{${string}}", "${text}", values); |
| 923 | | try testReplaceVariables(allocator, "@dollar@{${string}}", "${text}", values); |
| 924 | | try testReplaceVariables(allocator, "@dollar@{@string@}", "${text}", values); |
| 1047 | try testReplaceVariablesCMake(allocator, "@string_at@", "@string@", values); |
| 1048 | try testReplaceVariablesCMake(allocator, "${string_at}", "@string@", values); |
| 1049 | try testReplaceVariablesCMake(allocator, "$@string_curly@", "${string}", values); |
| 1050 | try testReplaceVariablesCMake(allocator, "$${string_curly}", "${string}", values); |
| 1051 | try testReplaceVariablesCMake(allocator, "${string_var}", "${string}", values); |
| 1052 | try testReplaceVariablesCMake(allocator, "@string_var@", "${string}", values); |
| 1053 | try testReplaceVariablesCMake(allocator, "${dollar}{${string}}", "${text}", values); |
| 1054 | try testReplaceVariablesCMake(allocator, "@dollar@{${string}}", "${text}", values); |
| 1055 | try testReplaceVariablesCMake(allocator, "@dollar@{@string@}", "${text}", values); |
| 925 | 1056 | |
| 926 | 1057 | // when expanded variables contain invalid characters, they prevent further expansion |
| 927 | | try std.testing.expectError(error.MissingValue, testReplaceVariables(allocator, "${${string_var}}", "", values)); |
| 928 | | try std.testing.expectError(error.MissingValue, testReplaceVariables(allocator, "${@string_var@}", "", values)); |
| 1058 | try std.testing.expectError(error.MissingValue, testReplaceVariablesCMake(allocator, "${${string_var}}", "", values)); |
| 1059 | try std.testing.expectError(error.MissingValue, testReplaceVariablesCMake(allocator, "${@string_var@}", "", values)); |
| 929 | 1060 | |
| 930 | 1061 | // nested expanded variables are expanded from the inside out |
| 931 | | try testReplaceVariables(allocator, "${string${underscore}proxy}", "string", values); |
| 932 | | try testReplaceVariables(allocator, "${string@underscore@proxy}", "string", values); |
| 1062 | try testReplaceVariablesCMake(allocator, "${string${underscore}proxy}", "string", values); |
| 1063 | try testReplaceVariablesCMake(allocator, "${string@underscore@proxy}", "string", values); |
| 933 | 1064 | |
| 934 | 1065 | // nested vars are only expanded when ${} is closed |
| 935 | | try std.testing.expectError(error.MissingValue, testReplaceVariables(allocator, "@nest@underscore@proxy@", "", values)); |
| 936 | | try testReplaceVariables(allocator, "${nest${underscore}proxy}", "nest_underscore_proxy", values); |
| 937 | | try std.testing.expectError(error.MissingValue, testReplaceVariables(allocator, "@nest@@nest_underscore@underscore@proxy@@proxy@", "", values)); |
| 938 | | try testReplaceVariables(allocator, "${nest${${nest_underscore${underscore}proxy}}proxy}", "nest_underscore_proxy", values); |
| 1066 | try std.testing.expectError(error.MissingValue, testReplaceVariablesCMake(allocator, "@nest@underscore@proxy@", "", values)); |
| 1067 | try testReplaceVariablesCMake(allocator, "${nest${underscore}proxy}", "nest_underscore_proxy", values); |
| 1068 | try std.testing.expectError(error.MissingValue, testReplaceVariablesCMake(allocator, "@nest@@nest_underscore@underscore@proxy@@proxy@", "", values)); |
| 1069 | try testReplaceVariablesCMake(allocator, "${nest${${nest_underscore${underscore}proxy}}proxy}", "nest_underscore_proxy", values); |
| 939 | 1070 | |
| 940 | 1071 | // invalid characters lead to an error |
| 941 | | try std.testing.expectError(error.InvalidCharacter, testReplaceVariables(allocator, "${str*ing}", "", values)); |
| 942 | | try std.testing.expectError(error.InvalidCharacter, testReplaceVariables(allocator, "${str$ing}", "", values)); |
| 943 | | try std.testing.expectError(error.InvalidCharacter, testReplaceVariables(allocator, "${str@ing}", "", values)); |
| 1072 | try std.testing.expectError(error.InvalidCharacter, testReplaceVariablesCMake(allocator, "${str*ing}", "", values)); |
| 1073 | try std.testing.expectError(error.InvalidCharacter, testReplaceVariablesCMake(allocator, "${str$ing}", "", values)); |
| 1074 | try std.testing.expectError(error.InvalidCharacter, testReplaceVariablesCMake(allocator, "${str@ing}", "", values)); |
| 944 | 1075 | } |
| 945 | 1076 | |
| 946 | 1077 | test "expand_variables_cmake escaped characters" { |
| ... | ... | @@ -951,14 +1082,14 @@ test "expand_variables_cmake escaped characters" { |
| 951 | 1082 | try values.putNoClobber("string", Value{ .string = "text" }); |
| 952 | 1083 | |
| 953 | 1084 | // backslash is an invalid character for @ lookup |
| 954 | | try testReplaceVariables(allocator, "\\@string\\@", "\\@string\\@", values); |
| 1085 | try testReplaceVariablesCMake(allocator, "\\@string\\@", "\\@string\\@", values); |
| 955 | 1086 | |
| 956 | 1087 | // backslash is preserved, but doesn't affect ${} variable expansion |
| 957 | | try testReplaceVariables(allocator, "\\${string}", "\\text", values); |
| 1088 | try testReplaceVariablesCMake(allocator, "\\${string}", "\\text", values); |
| 958 | 1089 | |
| 959 | 1090 | // backslash breaks ${} opening bracket identification |
| 960 | | try testReplaceVariables(allocator, "$\\{string}", "$\\{string}", values); |
| 1091 | try testReplaceVariablesCMake(allocator, "$\\{string}", "$\\{string}", values); |
| 961 | 1092 | |
| 962 | 1093 | // backslash is skipped when checking for invalid characters, yet it mangles the key |
| 963 | | try std.testing.expectError(error.MissingValue, testReplaceVariables(allocator, "${string\\}", "", values)); |
| 1094 | try std.testing.expectError(error.MissingValue, testReplaceVariablesCMake(allocator, "${string\\}", "", values)); |
| 964 | 1095 | } |