home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

sync_test.go (606B)


      1 package org
      2 
      3 import "testing"
      4 
      5 func TestSluggify(t *testing.T) {
      6 	testCases := []struct {
      7 		input    string
      8 		expected string
      9 	}{{
     10 		input:    "",
     11 		expected: "",
     12 	}, {
     13 		input:    "abcde",
     14 		expected: "abcde",
     15 	}, {
     16 		input:    "abcde---",
     17 		expected: "abcde",
     18 	}, {
     19 		input:    "a-b c--de",
     20 		expected: "a-b-c-de",
     21 	}, {
     22 		input:    "a_bc__de",
     23 		expected: "a-bc-de",
     24 	}, {
     25 		input:    "abcde$[)",
     26 		expected: "abcde",
     27 	}}
     28 	for _, tc := range testCases {
     29 		output := sluggify(tc.input)
     30 		if output != tc.expected {
     31 			t.Errorf("input \"%s\": expected %s, got %s", tc.input, tc.expected, output)
     32 		}
     33 	}
     34 }