(t *testing.T)
| 22 | } |
| 23 | |
| 24 | func TestParse1(t *testing.T) { |
| 25 | style := `background: url("example;with;semicolons.jpg"); color: red; margin-right: 5px; content: "hello;world";` |
| 26 | p := MakeParser(style) |
| 27 | parsed, err := p.Parse() |
| 28 | if err != nil { |
| 29 | t.Fatalf("Parse failed: %v", err) |
| 30 | return |
| 31 | } |
| 32 | expected := map[string]string{ |
| 33 | "background": `url("example;with;semicolons.jpg")`, |
| 34 | "color": "red", |
| 35 | "margin-right": "5px", |
| 36 | "content": `"hello;world"`, |
| 37 | } |
| 38 | if err := compareMaps(parsed, expected); err != nil { |
| 39 | t.Fatalf("Parsed map does not match expected: %v", err) |
| 40 | } |
| 41 | |
| 42 | style = `margin-right: calc(10px + 5px); color: red; font-family: "Arial";` |
| 43 | p = MakeParser(style) |
| 44 | parsed, err = p.Parse() |
| 45 | if err != nil { |
| 46 | t.Fatalf("Parse failed: %v", err) |
| 47 | return |
| 48 | } |
| 49 | expected = map[string]string{ |
| 50 | "margin-right": `calc(10px + 5px)`, |
| 51 | "color": "red", |
| 52 | "font-family": `"Arial"`, |
| 53 | } |
| 54 | if err := compareMaps(parsed, expected); err != nil { |
| 55 | t.Fatalf("Parsed map does not match expected: %v", err) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | func TestParserErrors(t *testing.T) { |
| 60 | style := `hello more: bad;` |
nothing calls this directly
no test coverage detected