|  |  |  | @ -6,7 +6,7 @@ import ( | 
		
	
		
			
				|  |  |  |  | 	"code.ndumas.com/ndumas/wikilink-parser" | 
		
	
		
			
				|  |  |  |  | ) | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | func Test_ObsidianWikilinks_LinksIntext(t *testing.T) { | 
		
	
		
			
				|  |  |  |  | func Test_ObsidianWikilinks_LinksEndOfInput(t *testing.T) { | 
		
	
		
			
				|  |  |  |  | 	tcs := []struct { | 
		
	
		
			
				|  |  |  |  | 		name     string | 
		
	
		
			
				|  |  |  |  | 		in       string | 
		
	
	
		
			
				
					|  |  |  | @ -14,7 +14,7 @@ func Test_ObsidianWikilinks_LinksIntext(t *testing.T) { | 
		
	
		
			
				|  |  |  |  | 	}{ | 
		
	
		
			
				|  |  |  |  | 		{ | 
		
	
		
			
				|  |  |  |  | 			name: "wikilink", | 
		
	
		
			
				|  |  |  |  | 			in:   "this is a [[wikilink]]", | 
		
	
		
			
				|  |  |  |  | 			in:   "[[wikilink]]", | 
		
	
		
			
				|  |  |  |  | 			expected: []wikilink.Lexeme{ | 
		
	
		
			
				|  |  |  |  | 				{Typ: wikilink.LexText, Val: "this is a "}, | 
		
	
		
			
				|  |  |  |  | 				{Typ: wikilink.LexOpenLink, Val: "[["}, | 
		
	
	
		
			
				
					|  |  |  | @ -25,7 +25,7 @@ func Test_ObsidianWikilinks_LinksIntext(t *testing.T) { | 
		
	
		
			
				|  |  |  |  | 		}, | 
		
	
		
			
				|  |  |  |  | 		{ | 
		
	
		
			
				|  |  |  |  | 			name: "wikilink|display name", | 
		
	
		
			
				|  |  |  |  | 			in:   "this is a [[wikilink|display name]]", | 
		
	
		
			
				|  |  |  |  | 			in:   "is a [[wikilink|display name]]", | 
		
	
		
			
				|  |  |  |  | 			expected: []wikilink.Lexeme{ | 
		
	
		
			
				|  |  |  |  | 				{Typ: wikilink.LexText, Val: "this is a "}, | 
		
	
		
			
				|  |  |  |  | 				{Typ: wikilink.LexOpenLink, Val: "[["}, | 
		
	
	
		
			
				
					|  |  |  | @ -457,33 +457,45 @@ func Test_ObsidianWikilinks_Basic(t *testing.T) { | 
		
	
		
			
				|  |  |  |  | 	} | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 	for _, tc := range tcs { | 
		
	
		
			
				|  |  |  |  | 		tc := tc | 
		
	
		
			
				|  |  |  |  | 		t.Run(tc.name, func(t *testing.T) { | 
		
	
		
			
				|  |  |  |  | 			// t.Parallel()
 | 
		
	
		
			
				|  |  |  |  | 			l := wikilink.Lex("testLexer", tc.in) | 
		
	
		
			
				|  |  |  |  | 			defer l.L.Sync() | 
		
	
		
			
				|  |  |  |  | 			if len(tc.expected) != len(l.Items) { | 
		
	
		
			
				|  |  |  |  | 				t.Logf("expected %d tokens, got %d\n", len(tc.expected), len(l.Items)) | 
		
	
		
			
				|  |  |  |  | 		mut, test := mutateTestCase(tc, "", "") | 
		
	
		
			
				|  |  |  |  | 		t.Run(mut.name, test) | 
		
	
		
			
				|  |  |  |  | 	} | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | type tc struct { | 
		
	
		
			
				|  |  |  |  | 	name     string | 
		
	
		
			
				|  |  |  |  | 	in       string | 
		
	
		
			
				|  |  |  |  | 	expected []wikilink.Lexeme | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | func mutateTestCase(tc tc, prefix, suffix string) (tc, func(t *testing.T)) { | 
		
	
		
			
				|  |  |  |  | 	tc.in = prefix + tc.in | 
		
	
		
			
				|  |  |  |  | 	tc.in = tc.in + suffix | 
		
	
		
			
				|  |  |  |  | 	return tc, func(t *testing.T) { | 
		
	
		
			
				|  |  |  |  | 		// t.Parallel()
 | 
		
	
		
			
				|  |  |  |  | 		l := wikilink.Lex("testLexer", tc.in) | 
		
	
		
			
				|  |  |  |  | 		defer l.L.Sync() | 
		
	
		
			
				|  |  |  |  | 		if len(tc.expected) != len(l.Items) { | 
		
	
		
			
				|  |  |  |  | 			t.Logf("expected %d tokens, got %d\n", len(tc.expected), len(l.Items)) | 
		
	
		
			
				|  |  |  |  | 			t.Fail() | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 			return | 
		
	
		
			
				|  |  |  |  | 		} | 
		
	
		
			
				|  |  |  |  | 		for i, e := range tc.expected { | 
		
	
		
			
				|  |  |  |  | 			n := l.Items[i] | 
		
	
		
			
				|  |  |  |  | 			if e.Typ != n.Typ { | 
		
	
		
			
				|  |  |  |  | 				t.Logf("expected Type %s, received %s", e.Typ.String(), n.Typ.String()) | 
		
	
		
			
				|  |  |  |  | 				t.Fail() | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 				return | 
		
	
		
			
				|  |  |  |  | 			} | 
		
	
		
			
				|  |  |  |  | 			for i, e := range tc.expected { | 
		
	
		
			
				|  |  |  |  | 				n := l.Items[i] | 
		
	
		
			
				|  |  |  |  | 				if e.Typ != n.Typ { | 
		
	
		
			
				|  |  |  |  | 					t.Logf("expected Type %s, received %s", e.Typ.String(), n.Typ.String()) | 
		
	
		
			
				|  |  |  |  | 					t.Fail() | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 					return | 
		
	
		
			
				|  |  |  |  | 				} | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 				if e.Val != n.Val { | 
		
	
		
			
				|  |  |  |  | 					t.Logf("expected Value %q, received %q", e.Val, n.Val) | 
		
	
		
			
				|  |  |  |  | 					t.Fail() | 
		
	
		
			
				|  |  |  |  | 			if e.Val != n.Val { | 
		
	
		
			
				|  |  |  |  | 				t.Logf("expected Value %q, received %q", e.Val, n.Val) | 
		
	
		
			
				|  |  |  |  | 				t.Fail() | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 					return | 
		
	
		
			
				|  |  |  |  | 				} | 
		
	
		
			
				|  |  |  |  | 				return | 
		
	
		
			
				|  |  |  |  | 			} | 
		
	
		
			
				|  |  |  |  | 		}) | 
		
	
		
			
				|  |  |  |  | 		} | 
		
	
		
			
				|  |  |  |  | 	} | 
		
	
		
			
				|  |  |  |  | } | 
		
	
	
		
			
				
					|  |  |  | 
 |