|
| 1 | +## Description ############################################################################# |
| 2 | +# |
| 3 | +# HTML Back End: Tests related with the cell titles. |
| 4 | +# |
| 5 | +############################################################################################ |
| 6 | + |
| 7 | +@testset "Cell Titles" verbose = true begin |
| 8 | + @testset "Column Label Titles" begin |
| 9 | + matrix = [(i, j) for i in 1:2, j in 1:4] |
| 10 | + column_labels = [[(i, j) for j in 1:4] for i in 1:3] |
| 11 | + column_label_titles = [[1, 2, 3, 4], nothing, ["5", "6", "7", "8"]] |
| 12 | + |
| 13 | + expected = """ |
| 14 | +<table> |
| 15 | + <thead> |
| 16 | + <tr class = "columnLabelRow"> |
| 17 | + <th title = "1" style = "text-align: right; font-weight: bold;">(1, 1)</th> |
| 18 | + <th title = "2" style = "text-align: right; font-weight: bold;">(1, 2)</th> |
| 19 | + <th title = "3" style = "text-align: right; font-weight: bold;">(1, 3)</th> |
| 20 | + <th title = "4" style = "text-align: right; font-weight: bold;">(1, 4)</th> |
| 21 | + </tr> |
| 22 | + <tr class = "columnLabelRow"> |
| 23 | + <th style = "text-align: right;">(2, 1)</th> |
| 24 | + <th style = "text-align: right;">(2, 2)</th> |
| 25 | + <th style = "text-align: right;">(2, 3)</th> |
| 26 | + <th style = "text-align: right;">(2, 4)</th> |
| 27 | + </tr> |
| 28 | + <tr class = "columnLabelRow"> |
| 29 | + <th title = "5" style = "text-align: right;">(3, 1)</th> |
| 30 | + <th title = "6" style = "text-align: right;">(3, 2)</th> |
| 31 | + <th title = "7" style = "text-align: right;">(3, 3)</th> |
| 32 | + <th title = "8" style = "text-align: right;">(3, 4)</th> |
| 33 | + </tr> |
| 34 | + </thead> |
| 35 | + <tbody> |
| 36 | + <tr class = "dataRow"> |
| 37 | + <td style = "text-align: right;">(1, 1)</td> |
| 38 | + <td style = "text-align: right;">(1, 2)</td> |
| 39 | + <td style = "text-align: right;">(1, 3)</td> |
| 40 | + <td style = "text-align: right;">(1, 4)</td> |
| 41 | + </tr> |
| 42 | + <tr class = "dataRow"> |
| 43 | + <td style = "text-align: right;">(2, 1)</td> |
| 44 | + <td style = "text-align: right;">(2, 2)</td> |
| 45 | + <td style = "text-align: right;">(2, 3)</td> |
| 46 | + <td style = "text-align: right;">(2, 4)</td> |
| 47 | + </tr> |
| 48 | + </tbody> |
| 49 | +</table> |
| 50 | +""" |
| 51 | + |
| 52 | + result = pretty_table( |
| 53 | + String, |
| 54 | + matrix; |
| 55 | + backend = :html, |
| 56 | + column_labels = column_labels, |
| 57 | + column_label_titles = column_label_titles, |
| 58 | + ) |
| 59 | + |
| 60 | + @test result == expected |
| 61 | + end |
| 62 | + |
| 63 | + @testset "Errors" verbose = true begin |
| 64 | + matrix = [(i, j) for i in 1:2, j in 1:4] |
| 65 | + column_labels = [[(i, j) for j in 1:4] for i in 1:3] |
| 66 | + |
| 67 | + |
| 68 | + column_label_titles = [[1, 2, 3, 4], ["5", "6", "7", "8"]] |
| 69 | + @test_throws Exception pretty_table( |
| 70 | + matrix; |
| 71 | + backend = :html, |
| 72 | + column_labels = column_labels, |
| 73 | + column_label_titles = column_label_titles, |
| 74 | + ) |
| 75 | + |
| 76 | + column_label_titles = [[1, 2, 3, 4], nothing, ["5", "6", "7", "8", "9"]] |
| 77 | + @test_throws Exception pretty_table( |
| 78 | + matrix; |
| 79 | + backend = :html, |
| 80 | + column_labels = column_labels, |
| 81 | + column_label_titles = column_label_titles, |
| 82 | + ) |
| 83 | + |
| 84 | + column_label_titles = [[1, 2, 3], nothing, ["5", "6", "7", "8"]] |
| 85 | + @test_throws Exception pretty_table( |
| 86 | + matrix; |
| 87 | + backend = :html, |
| 88 | + column_labels = column_labels, |
| 89 | + column_label_titles = column_label_titles, |
| 90 | + ) |
| 91 | + end |
| 92 | +end |
0 commit comments