From 2988d97d545dbe327918c5bc87415a167e8f4981 Mon Sep 17 00:00:00 2001 From: "Pascal J. Bourguignon" Date: Fri, 28 Jul 2023 11:10:54 +0200 Subject: [PATCH] Added a user-friendly error message when processing bad :treat_as When the indentation after :treat_as mappings is wrong, we may get a symbol as ctype. The error signaled by gtype.gsub is not userfriendly, so instead, we test for symbols and issue a user friend error message in that case. --- lib/cmock_unityhelper_parser.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/cmock_unityhelper_parser.rb b/lib/cmock_unityhelper_parser.rb index 9f4beb77..57f2aeb1 100644 --- a/lib/cmock_unityhelper_parser.rb +++ b/lib/cmock_unityhelper_parser.rb @@ -35,6 +35,9 @@ def get_helper(ctype) def map_c_types c_types = {} @config.treat_as.each_pair do |ctype, expecttype| + if ctype.is_a?(Symbol) + raise ":treat_as expects a list of identifier: identifier mappings, but got a symbol: #{ctype}. Check the indentation in your project.yml" + end c_type = ctype.gsub(/\s+/, '_') if expecttype =~ /\*/ c_types[c_type] = "UNITY_TEST_ASSERT_EQUAL_#{expecttype.delete('*')}_ARRAY"