作者:andy52
项目:arduino-builde
func TestCTagsParserShouldDealWithStructs(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldDealWithStructs.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_PREPROC_SOURCE].([]*types.CTag)
require.Equal(t, 5, len(ctags))
idx := 0
require.Equal(t, "A_NEW_TYPE", ctags[idx].FunctionName)
require.Equal(t, "struct", ctags[idx].Kind)
idx++
require.Equal(t, "foo", ctags[idx].FunctionName)
require.Equal(t, "variable", ctags[idx].Kind)
require.Equal(t, "struct:A_NEW_TYPE", ctags[idx].Typeref)
idx++
require.Equal(t, "setup", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
idx++
require.Equal(t, "loop", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
idx++
require.Equal(t, "dostuff", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
}
作者:stevemarpl
项目:arduino-builde
func TestCTagsParserClassMembersAreFilteredOut(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserClassMembersAreFilteredOut.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{CTagsField: constants.CTX_CTAGS_OF_SOURCE}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_SOURCE].([]map[string]string)
require.Equal(t, 5, len(ctags))
idx := 0
require.Equal(t, "set_values", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "prototype", ctags[idx]["kind"])
require.Equal(t, "Rectangle", ctags[idx]["class"])
idx++
require.Equal(t, "area", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
require.Equal(t, "Rectangle", ctags[idx]["class"])
idx++
require.Equal(t, "set_values", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
require.Equal(t, "Rectangle", ctags[idx]["class"])
idx++
require.Equal(t, "setup", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
idx++
require.Equal(t, "loop", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
}
作者:stevemarpl
项目:arduino-builde
func TestCTagsParserFunctionPointer(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserFunctionPointer.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{CTagsField: constants.CTX_CTAGS_OF_SOURCE}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_SOURCE].([]map[string]string)
require.Equal(t, 4, len(ctags))
idx := 0
require.Equal(t, "t1Callback", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "variable", ctags[idx]["kind"])
idx++
require.Equal(t, "t1Callback", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
idx++
require.Equal(t, "setup", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
idx++
require.Equal(t, "loop", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
}
作者:stevemarpl
项目:arduino-builde
func TestCTagsParserFunctionPointers(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserFunctionPointers.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{CTagsField: constants.CTX_CTAGS_OF_SOURCE}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_SOURCE].([]map[string]string)
require.Equal(t, 5, len(ctags))
idx := 0
require.Equal(t, "setup", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
idx++
require.Equal(t, "loop", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
idx++
require.Equal(t, "func", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
idx++
require.Equal(t, "funcArr", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
require.Equal(t, "()", ctags[idx]["signature"])
idx++
require.Equal(t, "funcCombo", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
require.Equal(t, "(void (*(&in)[5])(int))", ctags[idx]["signature"])
}
作者:andy52
项目:arduino-builde
func TestCTagsParserFunctionPointers(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserFunctionPointers.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_PREPROC_SOURCE].([]*types.CTag)
require.Equal(t, 5, len(ctags))
idx := 0
require.Equal(t, "setup", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
idx++
require.Equal(t, "loop", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
idx++
require.Equal(t, "func", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
idx++
require.Equal(t, "funcArr", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "()", ctags[idx].Signature)
idx++
require.Equal(t, "funcCombo", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "(void (*(&in)[5])(int))", ctags[idx].Signature)
}
作者:andy52
项目:arduino-builde
func TestCTagsParserShouldListTemplates(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldListTemplates.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_PREPROC_SOURCE].([]*types.CTag)
require.Equal(t, 3, len(ctags))
idx := 0
require.Equal(t, "minimum", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "(T a, T b)", ctags[idx].Signature)
idx++
require.Equal(t, "setup", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
idx++
require.Equal(t, "loop", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
}
作者:andy52
项目:arduino-builde
func TestCTagsParserFunctionPointer(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserFunctionPointer.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_PREPROC_SOURCE].([]*types.CTag)
require.Equal(t, 4, len(ctags))
idx := 0
require.Equal(t, "t1Callback", ctags[idx].FunctionName)
require.Equal(t, "variable", ctags[idx].Kind)
idx++
require.Equal(t, "t1Callback", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
idx++
require.Equal(t, "setup", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
idx++
require.Equal(t, "loop", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
}
作者:andy52
项目:arduino-builde
func TestCTagsParserClassMembersAreFilteredOut(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserClassMembersAreFilteredOut.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_PREPROC_SOURCE].([]*types.CTag)
require.Equal(t, 5, len(ctags))
idx := 0
require.Equal(t, "set_values", ctags[idx].FunctionName)
require.Equal(t, "prototype", ctags[idx].Kind)
require.Equal(t, "Rectangle", ctags[idx].Class)
idx++
require.Equal(t, "area", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "Rectangle", ctags[idx].Class)
idx++
require.Equal(t, "set_values", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "Rectangle", ctags[idx].Class)
idx++
require.Equal(t, "setup", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
idx++
require.Equal(t, "loop", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
}
作者:stevemarpl
项目:arduino-builde
func TestCTagsParserShouldDealWithStructs(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldDealWithStructs.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{CTagsField: constants.CTX_CTAGS_OF_SOURCE}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_SOURCE].([]map[string]string)
require.Equal(t, 5, len(ctags))
idx := 0
require.Equal(t, "A_NEW_TYPE", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "struct", ctags[idx]["kind"])
idx++
require.Equal(t, "foo", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "variable", ctags[idx]["kind"])
require.Equal(t, "struct:A_NEW_TYPE", ctags[idx]["typeref"])
idx++
require.Equal(t, "setup", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
idx++
require.Equal(t, "loop", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
idx++
require.Equal(t, "dostuff", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
}
作者:stevemarpl
项目:arduino-builde
func TestCTagsParserShouldListTemplates(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldListTemplates.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{CTagsField: constants.CTX_CTAGS_OF_SOURCE}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_SOURCE].([]map[string]string)
require.Equal(t, 3, len(ctags))
idx := 0
require.Equal(t, "minimum", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
require.Equal(t, "(T a, T b)", ctags[idx]["signature"])
idx++
require.Equal(t, "setup", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
idx++
require.Equal(t, "loop", ctags[idx][constants.CTAGS_FIELD_FUNCTION_NAME])
require.Equal(t, "function", ctags[idx]["kind"])
}
作者:ricklo
项目:arduino-builde
func TestCTagsParserShouldDealWithClasses(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldDealWithClasses.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{PrototypesField: constants.CTX_PROTOTYPES}
ctagsParser.Run(context)
prototypes := context[constants.CTX_PROTOTYPES].([]string)
require.Equal(t, 0, len(prototypes))
}
作者:ricklo
项目:arduino-builde
func TestCTagsParserShouldDealFunctionWithDifferentSignatures(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldDealFunctionWithDifferentSignatures.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{PrototypesField: constants.CTX_PROTOTYPES}
ctagsParser.Run(context)
prototypes := context[constants.CTX_PROTOTYPES].([]string)
require.Equal(t, 1, len(prototypes))
require.Equal(t, "boolean getBytes( byte addr, int amount );", prototypes[0])
}
作者:andy52
项目:arduino-builde
func TestCTagsParserShouldListPrototypes(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldListPrototypes.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_PREPROC_SOURCE].([]*types.CTag)
require.Equal(t, 8, len(ctags))
idx := 0
require.Equal(t, "server", ctags[idx].FunctionName)
require.Equal(t, "variable", ctags[idx].Kind)
require.Equal(t, "/tmp/sketch7210316334309249705.cpp", ctags[idx].Filename)
idx++
require.Equal(t, "setup", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "/tmp/sketch7210316334309249705.cpp", ctags[idx].Filename)
idx++
require.Equal(t, "loop", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "/tmp/sketch7210316334309249705.cpp", ctags[idx].Filename)
idx++
require.Equal(t, "process", ctags[idx].FunctionName)
require.Equal(t, "prototype", ctags[idx].Kind)
require.Equal(t, "/tmp/sketch7210316334309249705.cpp", ctags[idx].Filename)
idx++
require.Equal(t, "process", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "/tmp/sketch7210316334309249705.cpp", ctags[idx].Filename)
idx++
require.Equal(t, "digitalCommand", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "/tmp/sketch7210316334309249705.cpp", ctags[idx].Filename)
idx++
require.Equal(t, "analogCommand", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "/tmp/sketch7210316334309249705.cpp", ctags[idx].Filename)
idx++
require.Equal(t, "modeCommand", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
require.Equal(t, "/tmp/sketch7210316334309249705.cpp", ctags[idx].Filename)
}
作者:ricklo
项目:arduino-builde
func TestCTagsParserStructWithFunctions(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserStructWithFunctions.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{PrototypesField: constants.CTX_PROTOTYPES}
ctagsParser.Run(context)
prototypes := context[constants.CTX_PROTOTYPES].([]string)
require.Equal(t, 2, len(prototypes))
require.Equal(t, "void setup();", prototypes[0])
require.Equal(t, "void loop();", prototypes[1])
}
作者:banditelo
项目:arduino-builde
func TestCTagsParserShouldDealWithStructs(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldDealWithStructs.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{PrototypesField: constants.CTX_PROTOTYPES}
ctagsParser.Run(context)
prototypes := context[constants.CTX_PROTOTYPES].([]*types.Prototype)
require.Equal(t, 3, len(prototypes))
require.Equal(t, "void setup();", prototypes[0].Prototype)
require.Equal(t, "void loop();", prototypes[1].Prototype)
require.Equal(t, "void dostuff(A_NEW_TYPE * bar);", prototypes[2].Prototype)
}
作者:ricklo
项目:arduino-builde
func TestCTagsParserShouldListTemplates(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldListTemplates.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{PrototypesField: constants.CTX_PROTOTYPES}
ctagsParser.Run(context)
prototypes := context[constants.CTX_PROTOTYPES].([]string)
require.Equal(t, 3, len(prototypes))
require.Equal(t, "template <typename T> T minimum (T a, T b);", prototypes[0])
require.Equal(t, "void setup();", prototypes[1])
require.Equal(t, "void loop();", prototypes[2])
}
作者:ricklo
项目:arduino-builde
func TestCTagsParserShouldListTemplates2(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldListTemplates2.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{PrototypesField: constants.CTX_PROTOTYPES}
ctagsParser.Run(context)
prototypes := context[constants.CTX_PROTOTYPES].([]string)
require.Equal(t, 4, len(prototypes))
require.Equal(t, "void setup();", prototypes[0])
require.Equal(t, "void loop();", prototypes[1])
require.Equal(t, "template <class T> int SRAM_writeAnything(int ee, const T& value);", prototypes[2])
require.Equal(t, "template <class T> int SRAM_readAnything(int ee, T& value);", prototypes[3])
}
作者:ricklo
项目:arduino-builde
func TestCTagsParserShouldDealWithMacros(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldDealWithMacros.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{PrototypesField: constants.CTX_PROTOTYPES}
ctagsParser.Run(context)
prototypes := context[constants.CTX_PROTOTYPES].([]string)
require.Equal(t, 5, len(prototypes))
require.Equal(t, "void setup();", prototypes[0])
require.Equal(t, "void loop();", prototypes[1])
require.Equal(t, "void debug();", prototypes[2])
require.Equal(t, "void disabledIsDefined();", prototypes[3])
require.Equal(t, "int useMyType(MyType type);", prototypes[4])
}
作者:ricklo
项目:arduino-builde
func TestCTagsParserShouldListPrototypes(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldListPrototypes.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{PrototypesField: constants.CTX_PROTOTYPES}
ctagsParser.Run(context)
prototypes := context[constants.CTX_PROTOTYPES].([]string)
require.Equal(t, 5, len(prototypes))
require.Equal(t, "void setup();", prototypes[0])
require.Equal(t, "void loop();", prototypes[1])
require.Equal(t, "void digitalCommand(YunClient client);", prototypes[2])
require.Equal(t, "void analogCommand(YunClient client);", prototypes[3])
require.Equal(t, "void modeCommand(YunClient client);", prototypes[4])
}
作者:andy52
项目:arduino-builde
func TestCTagsParserShouldDealWithClasses(t *testing.T) {
context := make(map[string]interface{})
bytes, err := ioutil.ReadFile(filepath.Join("ctags_output", "TestCTagsParserShouldDealWithClasses.txt"))
NoError(t, err)
context[constants.CTX_CTAGS_OUTPUT] = string(bytes)
ctagsParser := builder.CTagsParser{}
ctagsParser.Run(context)
ctags := context[constants.CTX_CTAGS_OF_PREPROC_SOURCE].([]*types.CTag)
require.Equal(t, 2, len(ctags))
idx := 0
require.Equal(t, "SleepCycle", ctags[idx].FunctionName)
require.Equal(t, "prototype", ctags[idx].Kind)
idx++
require.Equal(t, "SleepCycle", ctags[idx].FunctionName)
require.Equal(t, "function", ctags[idx].Kind)
}