2015-12-29 16:14:54 +03:00
|
|
|
// Copyright 2014 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// This file contains simple golden tests for various examples.
|
|
|
|
// Besides validating the results when the implementation changes,
|
|
|
|
// it provides a way to look at the generated code without having
|
|
|
|
// to execute the print statements in one's head.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-07-20 00:25:24 +03:00
|
|
|
"fmt"
|
2018-12-29 20:20:08 +03:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2015-12-29 16:14:54 +03:00
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Golden represents a test case.
|
|
|
|
type Golden struct {
|
|
|
|
name string
|
|
|
|
input string // input; the package clause is provided when running the test.
|
2019-07-18 05:53:12 +03:00
|
|
|
output string // expected output.
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
var golden = []Golden{
|
2018-03-09 19:55:00 +03:00
|
|
|
{"day", dayIn, dayOut},
|
|
|
|
{"offset", offsetIn, offsetOut},
|
|
|
|
{"gap", gapIn, gapOut},
|
|
|
|
{"num", numIn, numOut},
|
|
|
|
{"unum", unumIn, unumOut},
|
|
|
|
{"prime", primeIn, primeOut},
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
2016-05-21 15:34:12 +03:00
|
|
|
var goldenJSON = []Golden{
|
2018-03-09 19:55:00 +03:00
|
|
|
{"prime", primeJsonIn, primeJsonOut},
|
2016-01-19 22:54:00 +03:00
|
|
|
}
|
2018-03-08 22:51:11 +03:00
|
|
|
var goldenText = []Golden{
|
2018-03-09 19:55:00 +03:00
|
|
|
{"prime", primeTextIn, primeTextOut},
|
2018-03-08 22:51:11 +03:00
|
|
|
}
|
2016-01-19 22:54:00 +03:00
|
|
|
|
2016-12-20 15:57:15 +03:00
|
|
|
var goldenYAML = []Golden{
|
2018-03-09 19:55:00 +03:00
|
|
|
{"prime", primeYamlIn, primeYamlOut},
|
2016-12-20 15:57:15 +03:00
|
|
|
}
|
|
|
|
|
2016-10-26 18:59:55 +03:00
|
|
|
var goldenSQL = []Golden{
|
2018-03-09 19:55:00 +03:00
|
|
|
{"prime", primeSqlIn, primeSqlOut},
|
2016-10-26 18:59:55 +03:00
|
|
|
}
|
|
|
|
|
2019-07-20 00:25:24 +03:00
|
|
|
var goldenBSON = []Golden{
|
|
|
|
{"prime with BSON", primeBsonIn, primeBsonOut},
|
|
|
|
}
|
|
|
|
|
2016-10-26 18:59:55 +03:00
|
|
|
var goldenJSONAndSQL = []Golden{
|
2018-03-09 19:55:00 +03:00
|
|
|
{"prime", primeJsonAndSqlIn, primeJsonAndSqlOut},
|
2016-10-26 18:59:55 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 12:54:07 +03:00
|
|
|
var goldenTrimPrefix = []Golden{
|
2019-03-22 13:36:20 +03:00
|
|
|
{"trim prefix", trimPrefixIn, dayOut},
|
2019-03-22 12:54:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
var goldenWithPrefix = []Golden{
|
2019-03-22 13:36:20 +03:00
|
|
|
{"with prefix", dayIn, prefixedDayOut},
|
|
|
|
}
|
|
|
|
|
|
|
|
var goldenTrimAndAddPrefix = []Golden{
|
|
|
|
{"trim and add prefix", trimPrefixIn, trimmedPrefixedDayOut},
|
2018-02-06 03:48:43 +03:00
|
|
|
}
|
|
|
|
|
2015-12-29 16:14:54 +03:00
|
|
|
// Each example starts with "type XXX [u]int", with a single space separating them.
|
|
|
|
|
|
|
|
// Simple test: enumeration of type int starting at 0.
|
2018-03-09 19:55:00 +03:00
|
|
|
const dayIn = `type Day int
|
2015-12-29 16:14:54 +03:00
|
|
|
const (
|
|
|
|
Monday Day = iota
|
|
|
|
Tuesday
|
|
|
|
Wednesday
|
|
|
|
Thursday
|
|
|
|
Friday
|
|
|
|
Saturday
|
|
|
|
Sunday
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const dayOut = `
|
2018-01-03 17:35:09 +03:00
|
|
|
const _DayName = "MondayTuesdayWednesdayThursdayFridaySaturdaySunday"
|
2015-12-29 16:14:54 +03:00
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _DayIndex = [...]uint8{0, 6, 13, 22, 30, 36, 44, 50}
|
2015-12-29 16:14:54 +03:00
|
|
|
|
2019-05-04 05:47:28 +03:00
|
|
|
const _DayLowerName = "mondaytuesdaywednesdaythursdayfridaysaturdaysunday"
|
|
|
|
|
2015-12-29 16:14:54 +03:00
|
|
|
func (i Day) String() string {
|
2018-01-03 17:35:09 +03:00
|
|
|
if i < 0 || i >= Day(len(_DayIndex)-1) {
|
2015-12-29 16:14:54 +03:00
|
|
|
return fmt.Sprintf("Day(%d)", i)
|
|
|
|
}
|
2018-01-03 17:35:09 +03:00
|
|
|
return _DayName[_DayIndex[i]:_DayIndex[i+1]]
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
2018-03-09 14:32:26 +03:00
|
|
|
var _DayValues = []Day{0, 1, 2, 3, 4, 5, 6}
|
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _DayNameToValueMap = map[string]Day{
|
2019-05-04 05:47:28 +03:00
|
|
|
_DayName[0:6]: 0,
|
|
|
|
_DayLowerName[0:6]: 0,
|
|
|
|
_DayName[6:13]: 1,
|
|
|
|
_DayLowerName[6:13]: 1,
|
|
|
|
_DayName[13:22]: 2,
|
|
|
|
_DayLowerName[13:22]: 2,
|
|
|
|
_DayName[22:30]: 3,
|
|
|
|
_DayLowerName[22:30]: 3,
|
|
|
|
_DayName[30:36]: 4,
|
|
|
|
_DayLowerName[30:36]: 4,
|
|
|
|
_DayName[36:44]: 5,
|
|
|
|
_DayLowerName[36:44]: 5,
|
|
|
|
_DayName[44:50]: 6,
|
|
|
|
_DayLowerName[44:50]: 6,
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _DayNames = []string{
|
|
|
|
_DayName[0:6],
|
|
|
|
_DayName[6:13],
|
|
|
|
_DayName[13:22],
|
|
|
|
_DayName[22:30],
|
|
|
|
_DayName[30:36],
|
|
|
|
_DayName[36:44],
|
|
|
|
_DayName[44:50],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// DayString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2015-12-29 16:14:54 +03:00
|
|
|
func DayString(s string) (Day, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _DayNameToValueMap[s]; ok {
|
2015-12-29 16:14:54 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
|
|
|
}
|
2018-03-09 14:32:26 +03:00
|
|
|
|
|
|
|
// DayValues returns all values of the enum
|
|
|
|
func DayValues() []Day {
|
|
|
|
return _DayValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// DayStrings returns a slice of all String values of the enum
|
|
|
|
func DayStrings() []string {
|
|
|
|
strs := make([]string, len(_DayNames))
|
|
|
|
copy(strs, _DayNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsADay returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Day) IsADay() bool {
|
2018-03-09 14:32:26 +03:00
|
|
|
for _, v := range _DayValues {
|
|
|
|
if i == v {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2015-12-29 16:14:54 +03:00
|
|
|
`
|
|
|
|
|
2019-03-22 12:54:07 +03:00
|
|
|
const prefixedDayOut = `
|
|
|
|
const _DayName = "DayMondayDayTuesdayDayWednesdayDayThursdayDayFridayDaySaturdayDaySunday"
|
|
|
|
|
|
|
|
var _DayIndex = [...]uint8{0, 9, 19, 31, 42, 51, 62, 71}
|
|
|
|
|
2019-05-04 05:47:28 +03:00
|
|
|
const _DayLowerName = "daymondaydaytuesdaydaywednesdaydaythursdaydayfridaydaysaturdaydaysunday"
|
|
|
|
|
2019-03-22 12:54:07 +03:00
|
|
|
func (i Day) String() string {
|
|
|
|
if i < 0 || i >= Day(len(_DayIndex)-1) {
|
|
|
|
return fmt.Sprintf("Day(%d)", i)
|
|
|
|
}
|
|
|
|
return _DayName[_DayIndex[i]:_DayIndex[i+1]]
|
|
|
|
}
|
|
|
|
|
|
|
|
var _DayValues = []Day{0, 1, 2, 3, 4, 5, 6}
|
|
|
|
|
|
|
|
var _DayNameToValueMap = map[string]Day{
|
2019-05-04 05:47:28 +03:00
|
|
|
_DayName[0:9]: 0,
|
|
|
|
_DayLowerName[0:9]: 0,
|
|
|
|
_DayName[9:19]: 1,
|
|
|
|
_DayLowerName[9:19]: 1,
|
|
|
|
_DayName[19:31]: 2,
|
|
|
|
_DayLowerName[19:31]: 2,
|
|
|
|
_DayName[31:42]: 3,
|
|
|
|
_DayLowerName[31:42]: 3,
|
|
|
|
_DayName[42:51]: 4,
|
|
|
|
_DayLowerName[42:51]: 4,
|
|
|
|
_DayName[51:62]: 5,
|
|
|
|
_DayLowerName[51:62]: 5,
|
|
|
|
_DayName[62:71]: 6,
|
|
|
|
_DayLowerName[62:71]: 6,
|
2019-03-22 12:54:07 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _DayNames = []string{
|
|
|
|
_DayName[0:9],
|
|
|
|
_DayName[9:19],
|
|
|
|
_DayName[19:31],
|
|
|
|
_DayName[31:42],
|
|
|
|
_DayName[42:51],
|
|
|
|
_DayName[51:62],
|
|
|
|
_DayName[62:71],
|
|
|
|
}
|
|
|
|
|
2019-03-22 12:54:07 +03:00
|
|
|
// DayString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
|
|
|
func DayString(s string) (Day, error) {
|
|
|
|
if val, ok := _DayNameToValueMap[s]; ok {
|
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
|
|
|
}
|
|
|
|
|
|
|
|
// DayValues returns all values of the enum
|
|
|
|
func DayValues() []Day {
|
|
|
|
return _DayValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// DayStrings returns a slice of all String values of the enum
|
|
|
|
func DayStrings() []string {
|
|
|
|
strs := make([]string, len(_DayNames))
|
|
|
|
copy(strs, _DayNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2019-03-22 12:54:07 +03:00
|
|
|
// IsADay returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Day) IsADay() bool {
|
|
|
|
for _, v := range _DayValues {
|
|
|
|
if i == v {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2019-03-22 13:36:20 +03:00
|
|
|
const trimmedPrefixedDayOut = `
|
|
|
|
const _DayName = "NightMondayNightTuesdayNightWednesdayNightThursdayNightFridayNightSaturdayNightSunday"
|
|
|
|
|
|
|
|
var _DayIndex = [...]uint8{0, 11, 23, 37, 50, 61, 74, 85}
|
|
|
|
|
2019-05-04 05:47:28 +03:00
|
|
|
const _DayLowerName = "nightmondaynighttuesdaynightwednesdaynightthursdaynightfridaynightsaturdaynightsunday"
|
|
|
|
|
2019-03-22 13:36:20 +03:00
|
|
|
func (i Day) String() string {
|
|
|
|
if i < 0 || i >= Day(len(_DayIndex)-1) {
|
|
|
|
return fmt.Sprintf("Day(%d)", i)
|
|
|
|
}
|
|
|
|
return _DayName[_DayIndex[i]:_DayIndex[i+1]]
|
|
|
|
}
|
|
|
|
|
|
|
|
var _DayValues = []Day{0, 1, 2, 3, 4, 5, 6}
|
|
|
|
|
|
|
|
var _DayNameToValueMap = map[string]Day{
|
2019-05-04 05:47:28 +03:00
|
|
|
_DayName[0:11]: 0,
|
|
|
|
_DayLowerName[0:11]: 0,
|
|
|
|
_DayName[11:23]: 1,
|
|
|
|
_DayLowerName[11:23]: 1,
|
|
|
|
_DayName[23:37]: 2,
|
|
|
|
_DayLowerName[23:37]: 2,
|
|
|
|
_DayName[37:50]: 3,
|
|
|
|
_DayLowerName[37:50]: 3,
|
|
|
|
_DayName[50:61]: 4,
|
|
|
|
_DayLowerName[50:61]: 4,
|
|
|
|
_DayName[61:74]: 5,
|
|
|
|
_DayLowerName[61:74]: 5,
|
|
|
|
_DayName[74:85]: 6,
|
|
|
|
_DayLowerName[74:85]: 6,
|
2019-03-22 13:36:20 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _DayNames = []string{
|
|
|
|
_DayName[0:11],
|
|
|
|
_DayName[11:23],
|
|
|
|
_DayName[23:37],
|
|
|
|
_DayName[37:50],
|
|
|
|
_DayName[50:61],
|
|
|
|
_DayName[61:74],
|
|
|
|
_DayName[74:85],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// DayString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2015-12-29 16:14:54 +03:00
|
|
|
func DayString(s string) (Day, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _DayNameToValueMap[s]; ok {
|
2015-12-29 16:14:54 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
|
|
|
}
|
2018-03-09 14:32:26 +03:00
|
|
|
|
|
|
|
// DayValues returns all values of the enum
|
|
|
|
func DayValues() []Day {
|
|
|
|
return _DayValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// DayStrings returns a slice of all String values of the enum
|
|
|
|
func DayStrings() []string {
|
|
|
|
strs := make([]string, len(_DayNames))
|
|
|
|
copy(strs, _DayNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsADay returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Day) IsADay() bool {
|
2018-03-09 14:32:26 +03:00
|
|
|
for _, v := range _DayValues {
|
|
|
|
if i == v {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2015-12-29 16:14:54 +03:00
|
|
|
`
|
|
|
|
|
|
|
|
// Enumeration with an offset.
|
|
|
|
// Also includes a duplicate.
|
2018-03-09 19:55:00 +03:00
|
|
|
const offsetIn = `type Number int
|
2015-12-29 16:14:54 +03:00
|
|
|
const (
|
|
|
|
_ Number = iota
|
|
|
|
One
|
|
|
|
Two
|
|
|
|
Three
|
|
|
|
AnotherOne = One // Duplicate; note that AnotherOne doesn't appear below.
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const offsetOut = `
|
2018-01-03 17:35:09 +03:00
|
|
|
const _NumberName = "OneTwoThree"
|
2015-12-29 16:14:54 +03:00
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _NumberIndex = [...]uint8{0, 3, 6, 11}
|
2015-12-29 16:14:54 +03:00
|
|
|
|
2019-05-04 05:47:28 +03:00
|
|
|
const _NumberLowerName = "onetwothree"
|
|
|
|
|
2015-12-29 16:14:54 +03:00
|
|
|
func (i Number) String() string {
|
|
|
|
i -= 1
|
2018-01-03 17:35:09 +03:00
|
|
|
if i < 0 || i >= Number(len(_NumberIndex)-1) {
|
2015-12-29 16:14:54 +03:00
|
|
|
return fmt.Sprintf("Number(%d)", i+1)
|
|
|
|
}
|
2018-01-03 17:35:09 +03:00
|
|
|
return _NumberName[_NumberIndex[i]:_NumberIndex[i+1]]
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
2018-03-09 14:32:26 +03:00
|
|
|
var _NumberValues = []Number{1, 2, 3}
|
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _NumberNameToValueMap = map[string]Number{
|
2019-05-04 05:47:28 +03:00
|
|
|
_NumberName[0:3]: 1,
|
|
|
|
_NumberLowerName[0:3]: 1,
|
|
|
|
_NumberName[3:6]: 2,
|
|
|
|
_NumberLowerName[3:6]: 2,
|
|
|
|
_NumberName[6:11]: 3,
|
|
|
|
_NumberLowerName[6:11]: 3,
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _NumberNames = []string{
|
|
|
|
_NumberName[0:3],
|
|
|
|
_NumberName[3:6],
|
|
|
|
_NumberName[6:11],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// NumberString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2015-12-29 16:14:54 +03:00
|
|
|
func NumberString(s string) (Number, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _NumberNameToValueMap[s]; ok {
|
2015-12-29 16:14:54 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Number values", s)
|
|
|
|
}
|
2018-03-09 14:32:26 +03:00
|
|
|
|
|
|
|
// NumberValues returns all values of the enum
|
|
|
|
func NumberValues() []Number {
|
|
|
|
return _NumberValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// NumberStrings returns a slice of all String values of the enum
|
|
|
|
func NumberStrings() []string {
|
|
|
|
strs := make([]string, len(_NumberNames))
|
|
|
|
copy(strs, _NumberNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsANumber returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Number) IsANumber() bool {
|
2018-03-09 14:32:26 +03:00
|
|
|
for _, v := range _NumberValues {
|
|
|
|
if i == v {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2015-12-29 16:14:54 +03:00
|
|
|
`
|
|
|
|
|
|
|
|
// Gaps and an offset.
|
2018-03-09 19:55:00 +03:00
|
|
|
const gapIn = `type Gap int
|
2015-12-29 16:14:54 +03:00
|
|
|
const (
|
|
|
|
Two Gap = 2
|
|
|
|
Three Gap = 3
|
|
|
|
Five Gap = 5
|
|
|
|
Six Gap = 6
|
|
|
|
Seven Gap = 7
|
|
|
|
Eight Gap = 8
|
|
|
|
Nine Gap = 9
|
|
|
|
Eleven Gap = 11
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const gapOut = `
|
2015-12-29 16:14:54 +03:00
|
|
|
const (
|
2019-05-04 05:47:28 +03:00
|
|
|
_GapName_0 = "TwoThree"
|
|
|
|
_GapLowerName_0 = "twothree"
|
|
|
|
_GapName_1 = "FiveSixSevenEightNine"
|
|
|
|
_GapLowerName_1 = "fivesixseveneightnine"
|
|
|
|
_GapName_2 = "Eleven"
|
|
|
|
_GapLowerName_2 = "eleven"
|
2015-12-29 16:14:54 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2018-01-03 17:35:09 +03:00
|
|
|
_GapIndex_0 = [...]uint8{0, 3, 8}
|
|
|
|
_GapIndex_1 = [...]uint8{0, 4, 7, 12, 17, 21}
|
|
|
|
_GapIndex_2 = [...]uint8{0, 6}
|
2015-12-29 16:14:54 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func (i Gap) String() string {
|
|
|
|
switch {
|
|
|
|
case 2 <= i && i <= 3:
|
|
|
|
i -= 2
|
2018-01-03 17:35:09 +03:00
|
|
|
return _GapName_0[_GapIndex_0[i]:_GapIndex_0[i+1]]
|
2015-12-29 16:14:54 +03:00
|
|
|
case 5 <= i && i <= 9:
|
|
|
|
i -= 5
|
2018-01-03 17:35:09 +03:00
|
|
|
return _GapName_1[_GapIndex_1[i]:_GapIndex_1[i+1]]
|
2015-12-29 16:14:54 +03:00
|
|
|
case i == 11:
|
2018-01-03 17:35:09 +03:00
|
|
|
return _GapName_2
|
2015-12-29 16:14:54 +03:00
|
|
|
default:
|
|
|
|
return fmt.Sprintf("Gap(%d)", i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-09 14:32:26 +03:00
|
|
|
var _GapValues = []Gap{2, 3, 5, 6, 7, 8, 9, 11}
|
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _GapNameToValueMap = map[string]Gap{
|
2019-05-04 05:47:28 +03:00
|
|
|
_GapName_0[0:3]: 2,
|
|
|
|
_GapLowerName_0[0:3]: 2,
|
|
|
|
_GapName_0[3:8]: 3,
|
|
|
|
_GapLowerName_0[3:8]: 3,
|
|
|
|
_GapName_1[0:4]: 5,
|
|
|
|
_GapLowerName_1[0:4]: 5,
|
|
|
|
_GapName_1[4:7]: 6,
|
|
|
|
_GapLowerName_1[4:7]: 6,
|
|
|
|
_GapName_1[7:12]: 7,
|
|
|
|
_GapLowerName_1[7:12]: 7,
|
|
|
|
_GapName_1[12:17]: 8,
|
|
|
|
_GapLowerName_1[12:17]: 8,
|
|
|
|
_GapName_1[17:21]: 9,
|
|
|
|
_GapLowerName_1[17:21]: 9,
|
|
|
|
_GapName_2[0:6]: 11,
|
|
|
|
_GapLowerName_2[0:6]: 11,
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _GapNames = []string{
|
|
|
|
_GapName_0[0:3],
|
|
|
|
_GapName_0[3:8],
|
|
|
|
_GapName_1[0:4],
|
|
|
|
_GapName_1[4:7],
|
|
|
|
_GapName_1[7:12],
|
|
|
|
_GapName_1[12:17],
|
|
|
|
_GapName_1[17:21],
|
|
|
|
_GapName_2[0:6],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// GapString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2015-12-29 16:14:54 +03:00
|
|
|
func GapString(s string) (Gap, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _GapNameToValueMap[s]; ok {
|
2015-12-29 16:14:54 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Gap values", s)
|
|
|
|
}
|
2018-03-09 14:32:26 +03:00
|
|
|
|
|
|
|
// GapValues returns all values of the enum
|
|
|
|
func GapValues() []Gap {
|
|
|
|
return _GapValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// GapStrings returns a slice of all String values of the enum
|
|
|
|
func GapStrings() []string {
|
|
|
|
strs := make([]string, len(_GapNames))
|
|
|
|
copy(strs, _GapNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsAGap returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Gap) IsAGap() bool {
|
2018-03-09 14:32:26 +03:00
|
|
|
for _, v := range _GapValues {
|
|
|
|
if i == v {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2015-12-29 16:14:54 +03:00
|
|
|
`
|
|
|
|
|
|
|
|
// Signed integers spanning zero.
|
2018-03-09 19:55:00 +03:00
|
|
|
const numIn = `type Num int
|
2015-12-29 16:14:54 +03:00
|
|
|
const (
|
|
|
|
m_2 Num = -2 + iota
|
|
|
|
m_1
|
|
|
|
m0
|
|
|
|
m1
|
|
|
|
m2
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const numOut = `
|
2018-01-03 17:35:09 +03:00
|
|
|
const _NumName = "m_2m_1m0m1m2"
|
2015-12-29 16:14:54 +03:00
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _NumIndex = [...]uint8{0, 3, 6, 8, 10, 12}
|
2015-12-29 16:14:54 +03:00
|
|
|
|
2019-05-04 05:47:28 +03:00
|
|
|
const _NumLowerName = "m_2m_1m0m1m2"
|
|
|
|
|
2015-12-29 16:14:54 +03:00
|
|
|
func (i Num) String() string {
|
|
|
|
i -= -2
|
2018-01-03 17:35:09 +03:00
|
|
|
if i < 0 || i >= Num(len(_NumIndex)-1) {
|
2015-12-29 16:14:54 +03:00
|
|
|
return fmt.Sprintf("Num(%d)", i+-2)
|
|
|
|
}
|
2018-01-03 17:35:09 +03:00
|
|
|
return _NumName[_NumIndex[i]:_NumIndex[i+1]]
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
2018-03-09 14:32:26 +03:00
|
|
|
var _NumValues = []Num{-2, -1, 0, 1, 2}
|
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _NumNameToValueMap = map[string]Num{
|
2019-05-04 05:47:28 +03:00
|
|
|
_NumName[0:3]: -2,
|
|
|
|
_NumLowerName[0:3]: -2,
|
|
|
|
_NumName[3:6]: -1,
|
|
|
|
_NumLowerName[3:6]: -1,
|
|
|
|
_NumName[6:8]: 0,
|
|
|
|
_NumLowerName[6:8]: 0,
|
|
|
|
_NumName[8:10]: 1,
|
|
|
|
_NumLowerName[8:10]: 1,
|
|
|
|
_NumName[10:12]: 2,
|
|
|
|
_NumLowerName[10:12]: 2,
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _NumNames = []string{
|
|
|
|
_NumName[0:3],
|
|
|
|
_NumName[3:6],
|
|
|
|
_NumName[6:8],
|
|
|
|
_NumName[8:10],
|
|
|
|
_NumName[10:12],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// NumString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2015-12-29 16:14:54 +03:00
|
|
|
func NumString(s string) (Num, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _NumNameToValueMap[s]; ok {
|
2015-12-29 16:14:54 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Num values", s)
|
|
|
|
}
|
2018-03-09 14:32:26 +03:00
|
|
|
|
|
|
|
// NumValues returns all values of the enum
|
|
|
|
func NumValues() []Num {
|
|
|
|
return _NumValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// NumStrings returns a slice of all String values of the enum
|
|
|
|
func NumStrings() []string {
|
|
|
|
strs := make([]string, len(_NumNames))
|
|
|
|
copy(strs, _NumNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsANum returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Num) IsANum() bool {
|
2018-03-09 14:32:26 +03:00
|
|
|
for _, v := range _NumValues {
|
|
|
|
if i == v {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2015-12-29 16:14:54 +03:00
|
|
|
`
|
|
|
|
|
|
|
|
// Unsigned integers spanning zero.
|
2018-03-09 19:55:00 +03:00
|
|
|
const unumIn = `type Unum uint
|
2015-12-29 16:14:54 +03:00
|
|
|
const (
|
|
|
|
m_2 Unum = iota + 253
|
|
|
|
m_1
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
m0 Unum = iota
|
|
|
|
m1
|
|
|
|
m2
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const unumOut = `
|
2015-12-29 16:14:54 +03:00
|
|
|
const (
|
2019-05-04 05:47:28 +03:00
|
|
|
_UnumName_0 = "m0m1m2"
|
|
|
|
_UnumLowerName_0 = "m0m1m2"
|
|
|
|
_UnumName_1 = "m_2m_1"
|
|
|
|
_UnumLowerName_1 = "m_2m_1"
|
2015-12-29 16:14:54 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2018-01-03 17:35:09 +03:00
|
|
|
_UnumIndex_0 = [...]uint8{0, 2, 4, 6}
|
|
|
|
_UnumIndex_1 = [...]uint8{0, 3, 6}
|
2015-12-29 16:14:54 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func (i Unum) String() string {
|
|
|
|
switch {
|
|
|
|
case 0 <= i && i <= 2:
|
2018-01-03 17:35:09 +03:00
|
|
|
return _UnumName_0[_UnumIndex_0[i]:_UnumIndex_0[i+1]]
|
2015-12-29 16:14:54 +03:00
|
|
|
case 253 <= i && i <= 254:
|
|
|
|
i -= 253
|
2018-01-03 17:35:09 +03:00
|
|
|
return _UnumName_1[_UnumIndex_1[i]:_UnumIndex_1[i+1]]
|
2015-12-29 16:14:54 +03:00
|
|
|
default:
|
|
|
|
return fmt.Sprintf("Unum(%d)", i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-09 14:32:26 +03:00
|
|
|
var _UnumValues = []Unum{0, 1, 2, 253, 254}
|
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _UnumNameToValueMap = map[string]Unum{
|
2019-05-04 05:47:28 +03:00
|
|
|
_UnumName_0[0:2]: 0,
|
|
|
|
_UnumLowerName_0[0:2]: 0,
|
|
|
|
_UnumName_0[2:4]: 1,
|
|
|
|
_UnumLowerName_0[2:4]: 1,
|
|
|
|
_UnumName_0[4:6]: 2,
|
|
|
|
_UnumLowerName_0[4:6]: 2,
|
|
|
|
_UnumName_1[0:3]: 253,
|
|
|
|
_UnumLowerName_1[0:3]: 253,
|
|
|
|
_UnumName_1[3:6]: 254,
|
|
|
|
_UnumLowerName_1[3:6]: 254,
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _UnumNames = []string{
|
|
|
|
_UnumName_0[0:2],
|
|
|
|
_UnumName_0[2:4],
|
|
|
|
_UnumName_0[4:6],
|
|
|
|
_UnumName_1[0:3],
|
|
|
|
_UnumName_1[3:6],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// UnumString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2015-12-29 16:14:54 +03:00
|
|
|
func UnumString(s string) (Unum, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _UnumNameToValueMap[s]; ok {
|
2015-12-29 16:14:54 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Unum values", s)
|
|
|
|
}
|
2018-03-09 14:32:26 +03:00
|
|
|
|
|
|
|
// UnumValues returns all values of the enum
|
|
|
|
func UnumValues() []Unum {
|
|
|
|
return _UnumValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// UnumStrings returns a slice of all String values of the enum
|
|
|
|
func UnumStrings() []string {
|
|
|
|
strs := make([]string, len(_UnumNames))
|
|
|
|
copy(strs, _UnumNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsAUnum returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Unum) IsAUnum() bool {
|
2018-03-09 14:32:26 +03:00
|
|
|
for _, v := range _UnumValues {
|
|
|
|
if i == v {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2015-12-29 16:14:54 +03:00
|
|
|
`
|
|
|
|
|
|
|
|
// Enough gaps to trigger a map implementation of the method.
|
|
|
|
// Also includes a duplicate to test that it doesn't cause problems
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeIn = `type Prime int
|
2015-12-29 16:14:54 +03:00
|
|
|
const (
|
|
|
|
p2 Prime = 2
|
|
|
|
p3 Prime = 3
|
|
|
|
p5 Prime = 5
|
|
|
|
p7 Prime = 7
|
|
|
|
p77 Prime = 7 // Duplicate; note that p77 doesn't appear below.
|
|
|
|
p11 Prime = 11
|
|
|
|
p13 Prime = 13
|
|
|
|
p17 Prime = 17
|
|
|
|
p19 Prime = 19
|
|
|
|
p23 Prime = 23
|
|
|
|
p29 Prime = 29
|
|
|
|
p37 Prime = 31
|
|
|
|
p41 Prime = 41
|
|
|
|
p43 Prime = 43
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeOut = `
|
2018-01-03 17:35:09 +03:00
|
|
|
const _PrimeName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2019-05-04 05:47:28 +03:00
|
|
|
const _PrimeLowerName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2018-01-03 17:35:09 +03:00
|
|
|
|
|
|
|
var _PrimeMap = map[Prime]string{
|
|
|
|
2: _PrimeName[0:2],
|
|
|
|
3: _PrimeName[2:4],
|
|
|
|
5: _PrimeName[4:6],
|
|
|
|
7: _PrimeName[6:8],
|
|
|
|
11: _PrimeName[8:11],
|
|
|
|
13: _PrimeName[11:14],
|
|
|
|
17: _PrimeName[14:17],
|
|
|
|
19: _PrimeName[17:20],
|
|
|
|
23: _PrimeName[20:23],
|
|
|
|
29: _PrimeName[23:26],
|
|
|
|
31: _PrimeName[26:29],
|
|
|
|
41: _PrimeName[29:32],
|
|
|
|
43: _PrimeName[32:35],
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i Prime) String() string {
|
2018-01-03 17:35:09 +03:00
|
|
|
if str, ok := _PrimeMap[i]; ok {
|
2015-12-29 16:14:54 +03:00
|
|
|
return str
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("Prime(%d)", i)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
var _PrimeValues = []Prime{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 43}
|
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _PrimeNameToValueMap = map[string]Prime{
|
2019-05-04 05:47:28 +03:00
|
|
|
_PrimeName[0:2]: 2,
|
|
|
|
_PrimeLowerName[0:2]: 2,
|
|
|
|
_PrimeName[2:4]: 3,
|
|
|
|
_PrimeLowerName[2:4]: 3,
|
|
|
|
_PrimeName[4:6]: 5,
|
|
|
|
_PrimeLowerName[4:6]: 5,
|
|
|
|
_PrimeName[6:8]: 7,
|
|
|
|
_PrimeLowerName[6:8]: 7,
|
|
|
|
_PrimeName[8:11]: 11,
|
|
|
|
_PrimeLowerName[8:11]: 11,
|
|
|
|
_PrimeName[11:14]: 13,
|
|
|
|
_PrimeLowerName[11:14]: 13,
|
|
|
|
_PrimeName[14:17]: 17,
|
|
|
|
_PrimeLowerName[14:17]: 17,
|
|
|
|
_PrimeName[17:20]: 19,
|
|
|
|
_PrimeLowerName[17:20]: 19,
|
|
|
|
_PrimeName[20:23]: 23,
|
|
|
|
_PrimeLowerName[20:23]: 23,
|
|
|
|
_PrimeName[23:26]: 29,
|
|
|
|
_PrimeLowerName[23:26]: 29,
|
|
|
|
_PrimeName[26:29]: 31,
|
|
|
|
_PrimeLowerName[26:29]: 31,
|
|
|
|
_PrimeName[29:32]: 41,
|
|
|
|
_PrimeLowerName[29:32]: 41,
|
|
|
|
_PrimeName[32:35]: 43,
|
|
|
|
_PrimeLowerName[32:35]: 43,
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _PrimeNames = []string{
|
|
|
|
_PrimeName[0:2],
|
|
|
|
_PrimeName[2:4],
|
|
|
|
_PrimeName[4:6],
|
|
|
|
_PrimeName[6:8],
|
|
|
|
_PrimeName[8:11],
|
|
|
|
_PrimeName[11:14],
|
|
|
|
_PrimeName[14:17],
|
|
|
|
_PrimeName[17:20],
|
|
|
|
_PrimeName[20:23],
|
|
|
|
_PrimeName[23:26],
|
|
|
|
_PrimeName[26:29],
|
|
|
|
_PrimeName[29:32],
|
|
|
|
_PrimeName[32:35],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// PrimeString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2015-12-29 16:14:54 +03:00
|
|
|
func PrimeString(s string) (Prime, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
2015-12-29 16:14:54 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
|
|
|
}
|
2018-03-09 15:33:11 +03:00
|
|
|
|
|
|
|
// PrimeValues returns all values of the enum
|
|
|
|
func PrimeValues() []Prime {
|
|
|
|
return _PrimeValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// PrimeStrings returns a slice of all String values of the enum
|
|
|
|
func PrimeStrings() []string {
|
|
|
|
strs := make([]string, len(_PrimeNames))
|
|
|
|
copy(strs, _PrimeNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsAPrime returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Prime) IsAPrime() bool {
|
2018-03-09 15:33:11 +03:00
|
|
|
_, ok := _PrimeMap[i]
|
|
|
|
return ok
|
|
|
|
}
|
2015-12-29 16:14:54 +03:00
|
|
|
`
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeJsonIn = `type Prime int
|
2016-01-19 22:54:00 +03:00
|
|
|
const (
|
|
|
|
p2 Prime = 2
|
|
|
|
p3 Prime = 3
|
|
|
|
p5 Prime = 5
|
|
|
|
p7 Prime = 7
|
|
|
|
p77 Prime = 7 // Duplicate; note that p77 doesn't appear below.
|
|
|
|
p11 Prime = 11
|
|
|
|
p13 Prime = 13
|
|
|
|
p17 Prime = 17
|
|
|
|
p19 Prime = 19
|
|
|
|
p23 Prime = 23
|
|
|
|
p29 Prime = 29
|
|
|
|
p37 Prime = 31
|
|
|
|
p41 Prime = 41
|
|
|
|
p43 Prime = 43
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeJsonOut = `
|
2018-01-03 17:35:09 +03:00
|
|
|
const _PrimeName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2019-05-04 05:47:28 +03:00
|
|
|
const _PrimeLowerName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2018-01-03 17:35:09 +03:00
|
|
|
|
|
|
|
var _PrimeMap = map[Prime]string{
|
|
|
|
2: _PrimeName[0:2],
|
|
|
|
3: _PrimeName[2:4],
|
|
|
|
5: _PrimeName[4:6],
|
|
|
|
7: _PrimeName[6:8],
|
|
|
|
11: _PrimeName[8:11],
|
|
|
|
13: _PrimeName[11:14],
|
|
|
|
17: _PrimeName[14:17],
|
|
|
|
19: _PrimeName[17:20],
|
|
|
|
23: _PrimeName[20:23],
|
|
|
|
29: _PrimeName[23:26],
|
|
|
|
31: _PrimeName[26:29],
|
|
|
|
41: _PrimeName[29:32],
|
|
|
|
43: _PrimeName[32:35],
|
2016-01-19 22:54:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i Prime) String() string {
|
2018-01-03 17:35:09 +03:00
|
|
|
if str, ok := _PrimeMap[i]; ok {
|
2016-01-19 22:54:00 +03:00
|
|
|
return str
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("Prime(%d)", i)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
var _PrimeValues = []Prime{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 43}
|
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _PrimeNameToValueMap = map[string]Prime{
|
2019-05-04 05:47:28 +03:00
|
|
|
_PrimeName[0:2]: 2,
|
|
|
|
_PrimeLowerName[0:2]: 2,
|
|
|
|
_PrimeName[2:4]: 3,
|
|
|
|
_PrimeLowerName[2:4]: 3,
|
|
|
|
_PrimeName[4:6]: 5,
|
|
|
|
_PrimeLowerName[4:6]: 5,
|
|
|
|
_PrimeName[6:8]: 7,
|
|
|
|
_PrimeLowerName[6:8]: 7,
|
|
|
|
_PrimeName[8:11]: 11,
|
|
|
|
_PrimeLowerName[8:11]: 11,
|
|
|
|
_PrimeName[11:14]: 13,
|
|
|
|
_PrimeLowerName[11:14]: 13,
|
|
|
|
_PrimeName[14:17]: 17,
|
|
|
|
_PrimeLowerName[14:17]: 17,
|
|
|
|
_PrimeName[17:20]: 19,
|
|
|
|
_PrimeLowerName[17:20]: 19,
|
|
|
|
_PrimeName[20:23]: 23,
|
|
|
|
_PrimeLowerName[20:23]: 23,
|
|
|
|
_PrimeName[23:26]: 29,
|
|
|
|
_PrimeLowerName[23:26]: 29,
|
|
|
|
_PrimeName[26:29]: 31,
|
|
|
|
_PrimeLowerName[26:29]: 31,
|
|
|
|
_PrimeName[29:32]: 41,
|
|
|
|
_PrimeLowerName[29:32]: 41,
|
|
|
|
_PrimeName[32:35]: 43,
|
|
|
|
_PrimeLowerName[32:35]: 43,
|
2016-01-19 22:54:00 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _PrimeNames = []string{
|
|
|
|
_PrimeName[0:2],
|
|
|
|
_PrimeName[2:4],
|
|
|
|
_PrimeName[4:6],
|
|
|
|
_PrimeName[6:8],
|
|
|
|
_PrimeName[8:11],
|
|
|
|
_PrimeName[11:14],
|
|
|
|
_PrimeName[14:17],
|
|
|
|
_PrimeName[17:20],
|
|
|
|
_PrimeName[20:23],
|
|
|
|
_PrimeName[23:26],
|
|
|
|
_PrimeName[26:29],
|
|
|
|
_PrimeName[29:32],
|
|
|
|
_PrimeName[32:35],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// PrimeString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2016-01-19 22:54:00 +03:00
|
|
|
func PrimeString(s string) (Prime, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
2016-01-19 22:54:00 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
// PrimeValues returns all values of the enum
|
|
|
|
func PrimeValues() []Prime {
|
|
|
|
return _PrimeValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// PrimeStrings returns a slice of all String values of the enum
|
|
|
|
func PrimeStrings() []string {
|
|
|
|
strs := make([]string, len(_PrimeNames))
|
|
|
|
copy(strs, _PrimeNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsAPrime returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Prime) IsAPrime() bool {
|
2018-03-09 15:33:11 +03:00
|
|
|
_, ok := _PrimeMap[i]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2018-02-20 06:20:31 +03:00
|
|
|
// MarshalJSON implements the json.Marshaler interface for Prime
|
2016-01-19 22:54:00 +03:00
|
|
|
func (i Prime) MarshalJSON() ([]byte, error) {
|
|
|
|
return json.Marshal(i.String())
|
|
|
|
}
|
|
|
|
|
2018-02-20 06:20:31 +03:00
|
|
|
// UnmarshalJSON implements the json.Unmarshaler interface for Prime
|
2016-01-19 22:54:00 +03:00
|
|
|
func (i *Prime) UnmarshalJSON(data []byte) error {
|
|
|
|
var s string
|
|
|
|
if err := json.Unmarshal(data, &s); err != nil {
|
|
|
|
return fmt.Errorf("Prime should be a string, got %s", data)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
*i, err = PrimeString(s)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
`
|
2015-12-29 16:14:54 +03:00
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeTextIn = `type Prime int
|
2018-03-08 22:51:11 +03:00
|
|
|
const (
|
|
|
|
p2 Prime = 2
|
|
|
|
p3 Prime = 3
|
|
|
|
p5 Prime = 5
|
|
|
|
p7 Prime = 7
|
|
|
|
p77 Prime = 7 // Duplicate; note that p77 doesn't appear below.
|
|
|
|
p11 Prime = 11
|
|
|
|
p13 Prime = 13
|
|
|
|
p17 Prime = 17
|
|
|
|
p19 Prime = 19
|
|
|
|
p23 Prime = 23
|
|
|
|
p29 Prime = 29
|
|
|
|
p37 Prime = 31
|
|
|
|
p41 Prime = 41
|
|
|
|
p43 Prime = 43
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeTextOut = `
|
2018-03-08 22:51:11 +03:00
|
|
|
const _PrimeName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2019-05-04 05:47:28 +03:00
|
|
|
const _PrimeLowerName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2018-03-08 22:51:11 +03:00
|
|
|
|
|
|
|
var _PrimeMap = map[Prime]string{
|
|
|
|
2: _PrimeName[0:2],
|
|
|
|
3: _PrimeName[2:4],
|
|
|
|
5: _PrimeName[4:6],
|
|
|
|
7: _PrimeName[6:8],
|
|
|
|
11: _PrimeName[8:11],
|
|
|
|
13: _PrimeName[11:14],
|
|
|
|
17: _PrimeName[14:17],
|
|
|
|
19: _PrimeName[17:20],
|
|
|
|
23: _PrimeName[20:23],
|
|
|
|
29: _PrimeName[23:26],
|
|
|
|
31: _PrimeName[26:29],
|
|
|
|
41: _PrimeName[29:32],
|
|
|
|
43: _PrimeName[32:35],
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i Prime) String() string {
|
|
|
|
if str, ok := _PrimeMap[i]; ok {
|
|
|
|
return str
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("Prime(%d)", i)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
var _PrimeValues = []Prime{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 43}
|
|
|
|
|
2018-03-08 22:51:11 +03:00
|
|
|
var _PrimeNameToValueMap = map[string]Prime{
|
2019-05-04 05:47:28 +03:00
|
|
|
_PrimeName[0:2]: 2,
|
|
|
|
_PrimeLowerName[0:2]: 2,
|
|
|
|
_PrimeName[2:4]: 3,
|
|
|
|
_PrimeLowerName[2:4]: 3,
|
|
|
|
_PrimeName[4:6]: 5,
|
|
|
|
_PrimeLowerName[4:6]: 5,
|
|
|
|
_PrimeName[6:8]: 7,
|
|
|
|
_PrimeLowerName[6:8]: 7,
|
|
|
|
_PrimeName[8:11]: 11,
|
|
|
|
_PrimeLowerName[8:11]: 11,
|
|
|
|
_PrimeName[11:14]: 13,
|
|
|
|
_PrimeLowerName[11:14]: 13,
|
|
|
|
_PrimeName[14:17]: 17,
|
|
|
|
_PrimeLowerName[14:17]: 17,
|
|
|
|
_PrimeName[17:20]: 19,
|
|
|
|
_PrimeLowerName[17:20]: 19,
|
|
|
|
_PrimeName[20:23]: 23,
|
|
|
|
_PrimeLowerName[20:23]: 23,
|
|
|
|
_PrimeName[23:26]: 29,
|
|
|
|
_PrimeLowerName[23:26]: 29,
|
|
|
|
_PrimeName[26:29]: 31,
|
|
|
|
_PrimeLowerName[26:29]: 31,
|
|
|
|
_PrimeName[29:32]: 41,
|
|
|
|
_PrimeLowerName[29:32]: 41,
|
|
|
|
_PrimeName[32:35]: 43,
|
|
|
|
_PrimeLowerName[32:35]: 43,
|
2018-03-08 22:51:11 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _PrimeNames = []string{
|
|
|
|
_PrimeName[0:2],
|
|
|
|
_PrimeName[2:4],
|
|
|
|
_PrimeName[4:6],
|
|
|
|
_PrimeName[6:8],
|
|
|
|
_PrimeName[8:11],
|
|
|
|
_PrimeName[11:14],
|
|
|
|
_PrimeName[14:17],
|
|
|
|
_PrimeName[17:20],
|
|
|
|
_PrimeName[20:23],
|
|
|
|
_PrimeName[23:26],
|
|
|
|
_PrimeName[26:29],
|
|
|
|
_PrimeName[29:32],
|
|
|
|
_PrimeName[32:35],
|
|
|
|
}
|
|
|
|
|
2018-03-08 22:51:11 +03:00
|
|
|
// PrimeString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
|
|
|
func PrimeString(s string) (Prime, error) {
|
|
|
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
// PrimeValues returns all values of the enum
|
|
|
|
func PrimeValues() []Prime {
|
|
|
|
return _PrimeValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// PrimeStrings returns a slice of all String values of the enum
|
|
|
|
func PrimeStrings() []string {
|
|
|
|
strs := make([]string, len(_PrimeNames))
|
|
|
|
copy(strs, _PrimeNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsAPrime returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Prime) IsAPrime() bool {
|
2018-03-09 15:33:11 +03:00
|
|
|
_, ok := _PrimeMap[i]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2018-03-08 23:17:07 +03:00
|
|
|
// MarshalText implements the encoding.TextMarshaler interface for Prime
|
2018-03-08 22:51:11 +03:00
|
|
|
func (i Prime) MarshalText() ([]byte, error) {
|
|
|
|
return []byte(i.String()), nil
|
|
|
|
}
|
|
|
|
|
2018-04-10 04:09:18 +03:00
|
|
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for Prime
|
2018-03-08 22:51:11 +03:00
|
|
|
func (i *Prime) UnmarshalText(text []byte) error {
|
|
|
|
var err error
|
|
|
|
*i, err = PrimeString(string(text))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeYamlIn = `type Prime int
|
2016-12-20 15:57:15 +03:00
|
|
|
const (
|
|
|
|
p2 Prime = 2
|
|
|
|
p3 Prime = 3
|
|
|
|
p5 Prime = 5
|
|
|
|
p7 Prime = 7
|
|
|
|
p77 Prime = 7 // Duplicate; note that p77 doesn't appear below.
|
|
|
|
p11 Prime = 11
|
|
|
|
p13 Prime = 13
|
|
|
|
p17 Prime = 17
|
|
|
|
p19 Prime = 19
|
|
|
|
p23 Prime = 23
|
|
|
|
p29 Prime = 29
|
|
|
|
p37 Prime = 31
|
|
|
|
p41 Prime = 41
|
|
|
|
p43 Prime = 43
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeYamlOut = `
|
2018-01-03 17:35:09 +03:00
|
|
|
const _PrimeName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2019-05-04 05:47:28 +03:00
|
|
|
const _PrimeLowerName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2018-01-03 17:35:09 +03:00
|
|
|
|
|
|
|
var _PrimeMap = map[Prime]string{
|
|
|
|
2: _PrimeName[0:2],
|
|
|
|
3: _PrimeName[2:4],
|
|
|
|
5: _PrimeName[4:6],
|
|
|
|
7: _PrimeName[6:8],
|
|
|
|
11: _PrimeName[8:11],
|
|
|
|
13: _PrimeName[11:14],
|
|
|
|
17: _PrimeName[14:17],
|
|
|
|
19: _PrimeName[17:20],
|
|
|
|
23: _PrimeName[20:23],
|
|
|
|
29: _PrimeName[23:26],
|
|
|
|
31: _PrimeName[26:29],
|
|
|
|
41: _PrimeName[29:32],
|
|
|
|
43: _PrimeName[32:35],
|
2016-12-20 15:57:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i Prime) String() string {
|
2018-01-03 17:35:09 +03:00
|
|
|
if str, ok := _PrimeMap[i]; ok {
|
2016-12-20 15:57:15 +03:00
|
|
|
return str
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("Prime(%d)", i)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
var _PrimeValues = []Prime{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 43}
|
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _PrimeNameToValueMap = map[string]Prime{
|
2019-05-04 05:47:28 +03:00
|
|
|
_PrimeName[0:2]: 2,
|
|
|
|
_PrimeLowerName[0:2]: 2,
|
|
|
|
_PrimeName[2:4]: 3,
|
|
|
|
_PrimeLowerName[2:4]: 3,
|
|
|
|
_PrimeName[4:6]: 5,
|
|
|
|
_PrimeLowerName[4:6]: 5,
|
|
|
|
_PrimeName[6:8]: 7,
|
|
|
|
_PrimeLowerName[6:8]: 7,
|
|
|
|
_PrimeName[8:11]: 11,
|
|
|
|
_PrimeLowerName[8:11]: 11,
|
|
|
|
_PrimeName[11:14]: 13,
|
|
|
|
_PrimeLowerName[11:14]: 13,
|
|
|
|
_PrimeName[14:17]: 17,
|
|
|
|
_PrimeLowerName[14:17]: 17,
|
|
|
|
_PrimeName[17:20]: 19,
|
|
|
|
_PrimeLowerName[17:20]: 19,
|
|
|
|
_PrimeName[20:23]: 23,
|
|
|
|
_PrimeLowerName[20:23]: 23,
|
|
|
|
_PrimeName[23:26]: 29,
|
|
|
|
_PrimeLowerName[23:26]: 29,
|
|
|
|
_PrimeName[26:29]: 31,
|
|
|
|
_PrimeLowerName[26:29]: 31,
|
|
|
|
_PrimeName[29:32]: 41,
|
|
|
|
_PrimeLowerName[29:32]: 41,
|
|
|
|
_PrimeName[32:35]: 43,
|
|
|
|
_PrimeLowerName[32:35]: 43,
|
2016-12-20 15:57:15 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _PrimeNames = []string{
|
|
|
|
_PrimeName[0:2],
|
|
|
|
_PrimeName[2:4],
|
|
|
|
_PrimeName[4:6],
|
|
|
|
_PrimeName[6:8],
|
|
|
|
_PrimeName[8:11],
|
|
|
|
_PrimeName[11:14],
|
|
|
|
_PrimeName[14:17],
|
|
|
|
_PrimeName[17:20],
|
|
|
|
_PrimeName[20:23],
|
|
|
|
_PrimeName[23:26],
|
|
|
|
_PrimeName[26:29],
|
|
|
|
_PrimeName[29:32],
|
|
|
|
_PrimeName[32:35],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// PrimeString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2016-12-20 15:57:15 +03:00
|
|
|
func PrimeString(s string) (Prime, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
2016-12-20 15:57:15 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
// PrimeValues returns all values of the enum
|
|
|
|
func PrimeValues() []Prime {
|
|
|
|
return _PrimeValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// PrimeStrings returns a slice of all String values of the enum
|
|
|
|
func PrimeStrings() []string {
|
|
|
|
strs := make([]string, len(_PrimeNames))
|
|
|
|
copy(strs, _PrimeNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsAPrime returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Prime) IsAPrime() bool {
|
2018-03-09 15:33:11 +03:00
|
|
|
_, ok := _PrimeMap[i]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2018-03-08 23:17:07 +03:00
|
|
|
// MarshalYAML implements a YAML Marshaler for Prime
|
2016-12-20 15:57:15 +03:00
|
|
|
func (i Prime) MarshalYAML() (interface{}, error) {
|
|
|
|
return i.String(), nil
|
|
|
|
}
|
|
|
|
|
2018-03-08 23:17:07 +03:00
|
|
|
// UnmarshalYAML implements a YAML Unmarshaler for Prime
|
2016-12-20 15:57:15 +03:00
|
|
|
func (i *Prime) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
|
|
var s string
|
|
|
|
if err := unmarshal(&s); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
*i, err = PrimeString(s)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeSqlIn = `type Prime int
|
2016-10-26 18:59:55 +03:00
|
|
|
const (
|
|
|
|
p2 Prime = 2
|
|
|
|
p3 Prime = 3
|
|
|
|
p5 Prime = 5
|
|
|
|
p7 Prime = 7
|
|
|
|
p77 Prime = 7 // Duplicate; note that p77 doesn't appear below.
|
|
|
|
p11 Prime = 11
|
|
|
|
p13 Prime = 13
|
|
|
|
p17 Prime = 17
|
|
|
|
p19 Prime = 19
|
|
|
|
p23 Prime = 23
|
|
|
|
p29 Prime = 29
|
|
|
|
p37 Prime = 31
|
|
|
|
p41 Prime = 41
|
|
|
|
p43 Prime = 43
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeSqlOut = `
|
2018-01-03 17:35:09 +03:00
|
|
|
const _PrimeName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2019-05-04 05:47:28 +03:00
|
|
|
const _PrimeLowerName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2018-01-03 17:35:09 +03:00
|
|
|
|
|
|
|
var _PrimeMap = map[Prime]string{
|
|
|
|
2: _PrimeName[0:2],
|
|
|
|
3: _PrimeName[2:4],
|
|
|
|
5: _PrimeName[4:6],
|
|
|
|
7: _PrimeName[6:8],
|
|
|
|
11: _PrimeName[8:11],
|
|
|
|
13: _PrimeName[11:14],
|
|
|
|
17: _PrimeName[14:17],
|
|
|
|
19: _PrimeName[17:20],
|
|
|
|
23: _PrimeName[20:23],
|
|
|
|
29: _PrimeName[23:26],
|
|
|
|
31: _PrimeName[26:29],
|
|
|
|
41: _PrimeName[29:32],
|
|
|
|
43: _PrimeName[32:35],
|
2016-10-26 18:59:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i Prime) String() string {
|
2018-01-03 17:35:09 +03:00
|
|
|
if str, ok := _PrimeMap[i]; ok {
|
2016-10-26 18:59:55 +03:00
|
|
|
return str
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("Prime(%d)", i)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
var _PrimeValues = []Prime{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 43}
|
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _PrimeNameToValueMap = map[string]Prime{
|
2019-05-04 05:47:28 +03:00
|
|
|
_PrimeName[0:2]: 2,
|
|
|
|
_PrimeLowerName[0:2]: 2,
|
|
|
|
_PrimeName[2:4]: 3,
|
|
|
|
_PrimeLowerName[2:4]: 3,
|
|
|
|
_PrimeName[4:6]: 5,
|
|
|
|
_PrimeLowerName[4:6]: 5,
|
|
|
|
_PrimeName[6:8]: 7,
|
|
|
|
_PrimeLowerName[6:8]: 7,
|
|
|
|
_PrimeName[8:11]: 11,
|
|
|
|
_PrimeLowerName[8:11]: 11,
|
|
|
|
_PrimeName[11:14]: 13,
|
|
|
|
_PrimeLowerName[11:14]: 13,
|
|
|
|
_PrimeName[14:17]: 17,
|
|
|
|
_PrimeLowerName[14:17]: 17,
|
|
|
|
_PrimeName[17:20]: 19,
|
|
|
|
_PrimeLowerName[17:20]: 19,
|
|
|
|
_PrimeName[20:23]: 23,
|
|
|
|
_PrimeLowerName[20:23]: 23,
|
|
|
|
_PrimeName[23:26]: 29,
|
|
|
|
_PrimeLowerName[23:26]: 29,
|
|
|
|
_PrimeName[26:29]: 31,
|
|
|
|
_PrimeLowerName[26:29]: 31,
|
|
|
|
_PrimeName[29:32]: 41,
|
|
|
|
_PrimeLowerName[29:32]: 41,
|
|
|
|
_PrimeName[32:35]: 43,
|
|
|
|
_PrimeLowerName[32:35]: 43,
|
2016-10-26 18:59:55 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _PrimeNames = []string{
|
|
|
|
_PrimeName[0:2],
|
|
|
|
_PrimeName[2:4],
|
|
|
|
_PrimeName[4:6],
|
|
|
|
_PrimeName[6:8],
|
|
|
|
_PrimeName[8:11],
|
|
|
|
_PrimeName[11:14],
|
|
|
|
_PrimeName[14:17],
|
|
|
|
_PrimeName[17:20],
|
|
|
|
_PrimeName[20:23],
|
|
|
|
_PrimeName[23:26],
|
|
|
|
_PrimeName[26:29],
|
|
|
|
_PrimeName[29:32],
|
|
|
|
_PrimeName[32:35],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// PrimeString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2016-10-26 18:59:55 +03:00
|
|
|
func PrimeString(s string) (Prime, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
2016-10-26 18:59:55 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
// PrimeValues returns all values of the enum
|
|
|
|
func PrimeValues() []Prime {
|
|
|
|
return _PrimeValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// PrimeStrings returns a slice of all String values of the enum
|
|
|
|
func PrimeStrings() []string {
|
|
|
|
strs := make([]string, len(_PrimeNames))
|
|
|
|
copy(strs, _PrimeNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsAPrime returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Prime) IsAPrime() bool {
|
2018-03-09 15:33:11 +03:00
|
|
|
_, ok := _PrimeMap[i]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2016-10-26 18:59:55 +03:00
|
|
|
func (i Prime) Value() (driver.Value, error) {
|
|
|
|
return i.String(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *Prime) Scan(value interface{}) error {
|
|
|
|
if value == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
str, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
bytes, ok := value.([]byte)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("value is not a byte slice")
|
|
|
|
}
|
|
|
|
|
|
|
|
str = string(bytes[:])
|
|
|
|
}
|
|
|
|
|
|
|
|
val, err := PrimeString(str)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
*i = val
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2019-07-20 00:25:24 +03:00
|
|
|
const primeBsonIn = `type Prime int
|
|
|
|
const (
|
|
|
|
p2 Prime = 2
|
|
|
|
p3 Prime = 3
|
|
|
|
p5 Prime = 5
|
|
|
|
p7 Prime = 7
|
|
|
|
p77 Prime = 7 // Duplicate; note that p77 doesn't appear below.
|
|
|
|
p11 Prime = 11
|
|
|
|
p13 Prime = 13
|
|
|
|
p17 Prime = 17
|
|
|
|
p19 Prime = 19
|
|
|
|
p23 Prime = 23
|
|
|
|
p29 Prime = 29
|
|
|
|
p37 Prime = 31
|
|
|
|
p41 Prime = 41
|
|
|
|
p43 Prime = 43
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
|
|
|
const primeBsonOut = `
|
|
|
|
const _PrimeName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
|
|
|
const _PrimeLowerName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
|
|
|
|
|
|
|
var _PrimeMap = map[Prime]string{
|
|
|
|
2: _PrimeName[0:2],
|
|
|
|
3: _PrimeName[2:4],
|
|
|
|
5: _PrimeName[4:6],
|
|
|
|
7: _PrimeName[6:8],
|
|
|
|
11: _PrimeName[8:11],
|
|
|
|
13: _PrimeName[11:14],
|
|
|
|
17: _PrimeName[14:17],
|
|
|
|
19: _PrimeName[17:20],
|
|
|
|
23: _PrimeName[20:23],
|
|
|
|
29: _PrimeName[23:26],
|
|
|
|
31: _PrimeName[26:29],
|
|
|
|
41: _PrimeName[29:32],
|
|
|
|
43: _PrimeName[32:35],
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i Prime) String() string {
|
|
|
|
if str, ok := _PrimeMap[i]; ok {
|
|
|
|
return str
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("Prime(%d)", i)
|
|
|
|
}
|
|
|
|
|
|
|
|
var _PrimeValues = []Prime{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 43}
|
|
|
|
|
|
|
|
var _PrimeNameToValueMap = map[string]Prime{
|
|
|
|
_PrimeName[0:2]: 2,
|
|
|
|
_PrimeLowerName[0:2]: 2,
|
|
|
|
_PrimeName[2:4]: 3,
|
|
|
|
_PrimeLowerName[2:4]: 3,
|
|
|
|
_PrimeName[4:6]: 5,
|
|
|
|
_PrimeLowerName[4:6]: 5,
|
|
|
|
_PrimeName[6:8]: 7,
|
|
|
|
_PrimeLowerName[6:8]: 7,
|
|
|
|
_PrimeName[8:11]: 11,
|
|
|
|
_PrimeLowerName[8:11]: 11,
|
|
|
|
_PrimeName[11:14]: 13,
|
|
|
|
_PrimeLowerName[11:14]: 13,
|
|
|
|
_PrimeName[14:17]: 17,
|
|
|
|
_PrimeLowerName[14:17]: 17,
|
|
|
|
_PrimeName[17:20]: 19,
|
|
|
|
_PrimeLowerName[17:20]: 19,
|
|
|
|
_PrimeName[20:23]: 23,
|
|
|
|
_PrimeLowerName[20:23]: 23,
|
|
|
|
_PrimeName[23:26]: 29,
|
|
|
|
_PrimeLowerName[23:26]: 29,
|
|
|
|
_PrimeName[26:29]: 31,
|
|
|
|
_PrimeLowerName[26:29]: 31,
|
|
|
|
_PrimeName[29:32]: 41,
|
|
|
|
_PrimeLowerName[29:32]: 41,
|
|
|
|
_PrimeName[32:35]: 43,
|
|
|
|
_PrimeLowerName[32:35]: 43,
|
|
|
|
}
|
|
|
|
|
|
|
|
var _PrimeNames = []string{
|
|
|
|
_PrimeName[0:2],
|
|
|
|
_PrimeName[2:4],
|
|
|
|
_PrimeName[4:6],
|
|
|
|
_PrimeName[6:8],
|
|
|
|
_PrimeName[8:11],
|
|
|
|
_PrimeName[11:14],
|
|
|
|
_PrimeName[14:17],
|
|
|
|
_PrimeName[17:20],
|
|
|
|
_PrimeName[20:23],
|
|
|
|
_PrimeName[23:26],
|
|
|
|
_PrimeName[26:29],
|
|
|
|
_PrimeName[29:32],
|
|
|
|
_PrimeName[32:35],
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrimeString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
|
|
|
func PrimeString(s string) (Prime, error) {
|
|
|
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrimeValues returns all values of the enum
|
|
|
|
func PrimeValues() []Prime {
|
|
|
|
return _PrimeValues
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrimeStrings returns a slice of all String values of the enum
|
|
|
|
func PrimeStrings() []string {
|
|
|
|
strs := make([]string, len(_PrimeNames))
|
|
|
|
copy(strs, _PrimeNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsAPrime returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Prime) IsAPrime() bool {
|
|
|
|
_, ok := _PrimeMap[i]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalBSONValue implements the bson.ValueMarshaler interface for Prime
|
|
|
|
func (i Prime) MarshalBSONValue() (bsontype.Type, []byte, error) {
|
|
|
|
return bsontype.String, bsoncore.AppendString(nil, i.String()), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalBSONValue implements the bson.ValueUnmarshaler interface for Prime
|
|
|
|
func (i *Prime) UnmarshalBSONValue(t bsontype.Type, src []byte) error {
|
|
|
|
str, _, _ := bsoncore.ReadString(src)
|
|
|
|
var err error
|
|
|
|
*i, err = PrimeString(str)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeJsonAndSqlIn = `type Prime int
|
2016-10-26 18:59:55 +03:00
|
|
|
const (
|
|
|
|
p2 Prime = 2
|
|
|
|
p3 Prime = 3
|
|
|
|
p5 Prime = 5
|
|
|
|
p7 Prime = 7
|
|
|
|
p77 Prime = 7 // Duplicate; note that p77 doesn't appear below.
|
|
|
|
p11 Prime = 11
|
|
|
|
p13 Prime = 13
|
|
|
|
p17 Prime = 17
|
|
|
|
p19 Prime = 19
|
|
|
|
p23 Prime = 23
|
|
|
|
p29 Prime = 29
|
|
|
|
p37 Prime = 31
|
|
|
|
p41 Prime = 41
|
|
|
|
p43 Prime = 43
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2018-03-09 19:55:00 +03:00
|
|
|
const primeJsonAndSqlOut = `
|
2018-01-03 17:35:09 +03:00
|
|
|
const _PrimeName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2019-05-04 05:47:28 +03:00
|
|
|
const _PrimeLowerName = "p2p3p5p7p11p13p17p19p23p29p37p41p43"
|
2018-01-03 17:35:09 +03:00
|
|
|
|
|
|
|
var _PrimeMap = map[Prime]string{
|
|
|
|
2: _PrimeName[0:2],
|
|
|
|
3: _PrimeName[2:4],
|
|
|
|
5: _PrimeName[4:6],
|
|
|
|
7: _PrimeName[6:8],
|
|
|
|
11: _PrimeName[8:11],
|
|
|
|
13: _PrimeName[11:14],
|
|
|
|
17: _PrimeName[14:17],
|
|
|
|
19: _PrimeName[17:20],
|
|
|
|
23: _PrimeName[20:23],
|
|
|
|
29: _PrimeName[23:26],
|
|
|
|
31: _PrimeName[26:29],
|
|
|
|
41: _PrimeName[29:32],
|
|
|
|
43: _PrimeName[32:35],
|
2016-10-26 18:59:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i Prime) String() string {
|
2018-01-03 17:35:09 +03:00
|
|
|
if str, ok := _PrimeMap[i]; ok {
|
2016-10-26 18:59:55 +03:00
|
|
|
return str
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("Prime(%d)", i)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
var _PrimeValues = []Prime{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 43}
|
|
|
|
|
2018-01-03 17:35:09 +03:00
|
|
|
var _PrimeNameToValueMap = map[string]Prime{
|
2019-05-04 05:47:28 +03:00
|
|
|
_PrimeName[0:2]: 2,
|
|
|
|
_PrimeLowerName[0:2]: 2,
|
|
|
|
_PrimeName[2:4]: 3,
|
|
|
|
_PrimeLowerName[2:4]: 3,
|
|
|
|
_PrimeName[4:6]: 5,
|
|
|
|
_PrimeLowerName[4:6]: 5,
|
|
|
|
_PrimeName[6:8]: 7,
|
|
|
|
_PrimeLowerName[6:8]: 7,
|
|
|
|
_PrimeName[8:11]: 11,
|
|
|
|
_PrimeLowerName[8:11]: 11,
|
|
|
|
_PrimeName[11:14]: 13,
|
|
|
|
_PrimeLowerName[11:14]: 13,
|
|
|
|
_PrimeName[14:17]: 17,
|
|
|
|
_PrimeLowerName[14:17]: 17,
|
|
|
|
_PrimeName[17:20]: 19,
|
|
|
|
_PrimeLowerName[17:20]: 19,
|
|
|
|
_PrimeName[20:23]: 23,
|
|
|
|
_PrimeLowerName[20:23]: 23,
|
|
|
|
_PrimeName[23:26]: 29,
|
|
|
|
_PrimeLowerName[23:26]: 29,
|
|
|
|
_PrimeName[26:29]: 31,
|
|
|
|
_PrimeLowerName[26:29]: 31,
|
|
|
|
_PrimeName[29:32]: 41,
|
|
|
|
_PrimeLowerName[29:32]: 41,
|
|
|
|
_PrimeName[32:35]: 43,
|
|
|
|
_PrimeLowerName[32:35]: 43,
|
2016-10-26 18:59:55 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
var _PrimeNames = []string{
|
|
|
|
_PrimeName[0:2],
|
|
|
|
_PrimeName[2:4],
|
|
|
|
_PrimeName[4:6],
|
|
|
|
_PrimeName[6:8],
|
|
|
|
_PrimeName[8:11],
|
|
|
|
_PrimeName[11:14],
|
|
|
|
_PrimeName[14:17],
|
|
|
|
_PrimeName[17:20],
|
|
|
|
_PrimeName[20:23],
|
|
|
|
_PrimeName[23:26],
|
|
|
|
_PrimeName[26:29],
|
|
|
|
_PrimeName[29:32],
|
|
|
|
_PrimeName[32:35],
|
|
|
|
}
|
|
|
|
|
2018-02-06 03:09:28 +03:00
|
|
|
// PrimeString retrieves an enum value from the enum constants string name.
|
|
|
|
// Throws an error if the param is not part of the enum.
|
2016-10-26 18:59:55 +03:00
|
|
|
func PrimeString(s string) (Prime, error) {
|
2018-01-03 17:35:09 +03:00
|
|
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
2016-10-26 18:59:55 +03:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:33:11 +03:00
|
|
|
// PrimeValues returns all values of the enum
|
|
|
|
func PrimeValues() []Prime {
|
|
|
|
return _PrimeValues
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:56:38 +03:00
|
|
|
// PrimeStrings returns a slice of all String values of the enum
|
|
|
|
func PrimeStrings() []string {
|
|
|
|
strs := make([]string, len(_PrimeNames))
|
|
|
|
copy(strs, _PrimeNames)
|
|
|
|
return strs
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:44:41 +03:00
|
|
|
// IsAPrime returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
|
|
func (i Prime) IsAPrime() bool {
|
2018-03-09 15:33:11 +03:00
|
|
|
_, ok := _PrimeMap[i]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2018-02-20 06:20:31 +03:00
|
|
|
// MarshalJSON implements the json.Marshaler interface for Prime
|
2016-10-26 18:59:55 +03:00
|
|
|
func (i Prime) MarshalJSON() ([]byte, error) {
|
|
|
|
return json.Marshal(i.String())
|
|
|
|
}
|
|
|
|
|
2018-02-20 06:20:31 +03:00
|
|
|
// UnmarshalJSON implements the json.Unmarshaler interface for Prime
|
2016-10-26 18:59:55 +03:00
|
|
|
func (i *Prime) UnmarshalJSON(data []byte) error {
|
|
|
|
var s string
|
|
|
|
if err := json.Unmarshal(data, &s); err != nil {
|
|
|
|
return fmt.Errorf("Prime should be a string, got %s", data)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
*i, err = PrimeString(s)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i Prime) Value() (driver.Value, error) {
|
|
|
|
return i.String(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *Prime) Scan(value interface{}) error {
|
|
|
|
if value == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
str, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
bytes, ok := value.([]byte)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("value is not a byte slice")
|
|
|
|
}
|
|
|
|
|
|
|
|
str = string(bytes[:])
|
|
|
|
}
|
|
|
|
|
|
|
|
val, err := PrimeString(str)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
*i = val
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2019-03-22 12:54:07 +03:00
|
|
|
const trimPrefixIn = `type Day int
|
2018-02-06 03:48:43 +03:00
|
|
|
const (
|
|
|
|
DayMonday Day = iota
|
|
|
|
DayTuesday
|
|
|
|
DayWednesday
|
|
|
|
DayThursday
|
|
|
|
DayFriday
|
|
|
|
DaySaturday
|
|
|
|
DaySunday
|
|
|
|
)
|
|
|
|
`
|
|
|
|
|
2015-12-29 16:14:54 +03:00
|
|
|
func TestGolden(t *testing.T) {
|
|
|
|
for _, test := range golden {
|
2019-07-20 00:25:24 +03:00
|
|
|
runGoldenTest(t, test, false, false, false, false, false, "", "")
|
2016-01-19 22:54:00 +03:00
|
|
|
}
|
|
|
|
for _, test := range goldenJSON {
|
2019-07-20 00:25:24 +03:00
|
|
|
runGoldenTest(t, test, true, false, false, false, false, "", "")
|
2018-03-08 22:51:11 +03:00
|
|
|
}
|
|
|
|
for _, test := range goldenText {
|
2019-07-20 00:25:24 +03:00
|
|
|
runGoldenTest(t, test, false, false, false, true, false, "", "")
|
2016-12-20 15:57:15 +03:00
|
|
|
}
|
|
|
|
for _, test := range goldenYAML {
|
2019-07-20 00:25:24 +03:00
|
|
|
runGoldenTest(t, test, false, true, false, false, false, "", "")
|
2016-10-26 18:59:55 +03:00
|
|
|
}
|
|
|
|
for _, test := range goldenSQL {
|
2019-07-20 00:25:24 +03:00
|
|
|
runGoldenTest(t, test, false, false, true, false, false, "", "")
|
|
|
|
}
|
|
|
|
for _, test := range goldenBSON {
|
|
|
|
runGoldenTest(t, test, false, false, false, false, true, "", "")
|
2016-10-26 18:59:55 +03:00
|
|
|
}
|
|
|
|
for _, test := range goldenJSONAndSQL {
|
2019-07-20 00:25:24 +03:00
|
|
|
runGoldenTest(t, test, true, false, true, false, false, "", "")
|
2018-02-06 03:48:43 +03:00
|
|
|
}
|
2019-03-22 12:54:07 +03:00
|
|
|
for _, test := range goldenTrimPrefix {
|
2019-07-20 00:25:24 +03:00
|
|
|
runGoldenTest(t, test, false, false, false, false, false, "Day", "")
|
2018-02-06 03:48:43 +03:00
|
|
|
}
|
2019-03-22 12:54:07 +03:00
|
|
|
for _, test := range goldenWithPrefix {
|
2019-07-20 00:25:24 +03:00
|
|
|
runGoldenTest(t, test, false, false, false, false, false, "", "Day")
|
2016-01-19 22:54:00 +03:00
|
|
|
}
|
2019-03-22 13:36:20 +03:00
|
|
|
for _, test := range goldenTrimAndAddPrefix {
|
2019-07-20 00:25:24 +03:00
|
|
|
runGoldenTest(t, test, false, false, false, false, false, "Day", "Night")
|
2016-01-19 22:54:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-20 00:25:24 +03:00
|
|
|
func runGoldenTest(t *testing.T, test Golden, generateJSON, generateYAML, generateSQL, generateText, generateBSON bool, trimPrefix string, prefix string) {
|
2016-01-19 22:54:00 +03:00
|
|
|
var g Generator
|
|
|
|
file := test.name + ".go"
|
2018-12-29 20:20:08 +03:00
|
|
|
input := "package test\n" + test.input
|
|
|
|
|
|
|
|
dir, err := ioutil.TempDir("", "stringer")
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = os.RemoveAll(dir)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
absFile := filepath.Join(dir, file)
|
|
|
|
err = ioutil.WriteFile(absFile, []byte(input), 0644)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
g.parsePackage([]string{absFile}, nil)
|
2016-01-19 22:54:00 +03:00
|
|
|
// Extract the name and type of the constant from the first line.
|
|
|
|
tokens := strings.SplitN(test.input, " ", 3)
|
|
|
|
if len(tokens) != 3 {
|
|
|
|
t.Fatalf("%s: need type declaration on first line", test.name)
|
|
|
|
}
|
2019-07-20 00:25:24 +03:00
|
|
|
g.generate(tokens[1], generateJSON, generateYAML, generateSQL, generateText, generateBSON, "noop", trimPrefix, prefix, false)
|
2016-01-19 22:54:00 +03:00
|
|
|
got := string(g.format())
|
|
|
|
if got != test.output {
|
2019-05-04 05:47:28 +03:00
|
|
|
// Use this to help build a golden text when changes are needed
|
2019-07-20 00:25:24 +03:00
|
|
|
goldenFile := fmt.Sprintf("./goldendata/%v-%v-%v-%v-%v-%v-%v-%v-%v-%v-%v.golden", test.name, tokens[1], generateJSON, generateYAML, generateSQL, generateText, generateBSON, "noop", trimPrefix, prefix, false)
|
|
|
|
err = ioutil.WriteFile(goldenFile, []byte(got), 0644)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
2016-01-19 22:54:00 +03:00
|
|
|
t.Errorf("%s: got\n====\n%s====\nexpected\n====%s", test.name, got, test.output)
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
}
|