github.com/bytedance/sonic@v1.11.7-0.20240517092252-d2edb31b167b/decoder/testdata_test.go (about)

     1  /*
     2   * Copyright 2021 ByteDance Inc.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package decoder
    18  
    19  import (
    20    `os`
    21  )
    22  
    23  var (
    24    debugSyncGC  = os.Getenv("SONIC_SYNC_GC") != ""
    25    debugAsyncGC = os.Getenv("SONIC_NO_ASYNC_GC") == ""
    26  )
    27  
    28  
    29  const TwitterJson = `{
    30    "statuses": [
    31      {
    32        "coordinates": null,
    33        "favorited": false,
    34        "truncated": false,
    35        "created_at": "Mon Sep 24 03:35:21 +0000 2012",
    36        "id_str": "250075927172759552",
    37        "entities": {
    38          "urls": [
    39   
    40          ],
    41          "hashtags": [
    42            {
    43              "text": "freebandnames",
    44              "indices": [
    45                20,
    46                34
    47              ]
    48            }
    49          ],
    50          "user_mentions": [
    51   
    52          ]
    53        },
    54        "in_reply_to_user_id_str": null,
    55        "contributors": null,
    56        "text": "Aggressive Ponytail #freebandnames",
    57        "metadata": {
    58          "iso_language_code": "en",
    59          "result_type": "recent"
    60        },
    61        "retweet_count": 0,
    62        "in_reply_to_status_id_str": null,
    63        "id": 250075927172759552,
    64        "geo": null,
    65        "retweeted": false,
    66        "in_reply_to_user_id": null,
    67        "place": null,
    68        "user": {
    69          "profile_sidebar_fill_color": "DDEEF6",
    70          "profile_sidebar_border_color": "C0DEED",
    71          "profile_background_tile": false,
    72          "name": "Sean Cummings",
    73          "profile_image_url": "https://a0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg",
    74          "created_at": "Mon Apr 26 06:01:55 +0000 2010",
    75          "location": "LA, CA",
    76          "follow_request_sent": null,
    77          "profile_link_color": "0084B4",
    78          "is_translator": false,
    79          "id_str": "137238150",
    80          "entities": {
    81            "url": {
    82              "urls": [
    83                {
    84                  "expanded_url": null,
    85                  "url": "",
    86                  "indices": [
    87                    0,
    88                    0
    89                  ]
    90                }
    91              ]
    92            },
    93            "description": {
    94              "urls": [
    95   
    96              ]
    97            }
    98          },
    99          "default_profile": true,
   100          "contributors_enabled": false,
   101          "favourites_count": 0,
   102          "url": null,
   103          "profile_image_url_https": "https://si0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg",
   104          "utc_offset": -28800,
   105          "id": 137238150,
   106          "profile_use_background_image": true,
   107          "listed_count": 2,
   108          "profile_text_color": "333333",
   109          "lang": "en",
   110          "followers_count": 70,
   111          "protected": false,
   112          "notifications": null,
   113          "profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme1/bg.png",
   114          "profile_background_color": "C0DEED",
   115          "verified": false,
   116          "geo_enabled": true,
   117          "time_zone": "Pacific Time (US & Canada)",
   118          "description": "Born 330 Live 310",
   119          "default_profile_image": false,
   120          "profile_background_image_url": "https://a0.twimg.com/images/themes/theme1/bg.png",
   121          "statuses_count": 579,
   122          "friends_count": 110,
   123          "following": null,
   124          "show_all_inline_media": false,
   125          "screen_name": "sean_cummings"
   126        },
   127        "in_reply_to_screen_name": null,
   128        "source": "<a href=\"//itunes.apple.com/us/app/twitter/id409789998?mt=12%5C%22\" rel=\"\\\"nofollow\\\"\">Twitter for Mac</a>",
   129        "in_reply_to_status_id": null
   130      },
   131      {
   132        "coordinates": null,
   133        "favorited": false,
   134        "truncated": false,
   135        "created_at": "Fri Sep 21 23:40:54 +0000 2012",
   136        "id_str": "249292149810667520",
   137        "entities": {
   138          "urls": [
   139   
   140          ],
   141          "hashtags": [
   142            {
   143              "text": "FreeBandNames",
   144              "indices": [
   145                20,
   146                34
   147              ]
   148            }
   149          ],
   150          "user_mentions": [
   151   
   152          ]
   153        },
   154        "in_reply_to_user_id_str": null,
   155        "contributors": null,
   156        "text": "Thee Namaste Nerdz. #FreeBandNames",
   157        "metadata": {
   158          "iso_language_code": "pl",
   159          "result_type": "recent"
   160        },
   161        "retweet_count": 0,
   162        "in_reply_to_status_id_str": null,
   163        "id": 249292149810667520,
   164        "geo": null,
   165        "retweeted": false,
   166        "in_reply_to_user_id": null,
   167        "place": null,
   168        "user": {
   169          "profile_sidebar_fill_color": "DDFFCC",
   170          "profile_sidebar_border_color": "BDDCAD",
   171          "profile_background_tile": true,
   172          "name": "Chaz Martenstein",
   173          "profile_image_url": "https://a0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg",
   174          "created_at": "Tue Apr 07 19:05:07 +0000 2009",
   175          "location": "Durham, NC",
   176          "follow_request_sent": null,
   177          "profile_link_color": "0084B4",
   178          "is_translator": false,
   179          "id_str": "29516238",
   180          "entities": {
   181            "url": {
   182              "urls": [
   183                {
   184                  "expanded_url": null,
   185                  "url": "https://bullcityrecords.com/wnng/",
   186                  "indices": [
   187                    0,
   188                    32
   189                  ]
   190                }
   191              ]
   192            },
   193            "description": {
   194              "urls": [
   195   
   196              ]
   197            }
   198          },
   199          "default_profile": false,
   200          "contributors_enabled": false,
   201          "favourites_count": 8,
   202          "url": "https://bullcityrecords.com/wnng/",
   203          "profile_image_url_https": "https://si0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg",
   204          "utc_offset": -18000,
   205          "id": 29516238,
   206          "profile_use_background_image": true,
   207          "listed_count": 118,
   208          "profile_text_color": "333333",
   209          "lang": "en",
   210          "followers_count": 2052,
   211          "protected": false,
   212          "notifications": null,
   213          "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/9423277/background_tile.bmp",
   214          "profile_background_color": "9AE4E8",
   215          "verified": false,
   216          "geo_enabled": false,
   217          "time_zone": "Eastern Time (US & Canada)",
   218          "description": "You will come to Durham, North Carolina. I will sell you some records then, here in Durham, North Carolina. Fun will happen.",
   219          "default_profile_image": false,
   220          "profile_background_image_url": "https://a0.twimg.com/profile_background_images/9423277/background_tile.bmp",
   221          "statuses_count": 7579,
   222          "friends_count": 348,
   223          "following": null,
   224          "show_all_inline_media": true,
   225          "screen_name": "bullcityrecords"
   226        },
   227        "in_reply_to_screen_name": null,
   228        "source": "web",
   229        "in_reply_to_status_id": null
   230      },
   231      {
   232        "coordinates": null,
   233        "favorited": false,
   234        "truncated": false,
   235        "created_at": "Fri Sep 21 23:30:20 +0000 2012",
   236        "id_str": "249289491129438208",
   237        "entities": {
   238          "urls": [
   239   
   240          ],
   241          "hashtags": [
   242            {
   243              "text": "freebandnames",
   244              "indices": [
   245                29,
   246                43
   247              ]
   248            }
   249          ],
   250          "user_mentions": [
   251   
   252          ]
   253        },
   254        "in_reply_to_user_id_str": null,
   255        "contributors": null,
   256        "text": "Mexican Heaven, Mexican Hell #freebandnames",
   257        "metadata": {
   258          "iso_language_code": "en",
   259          "result_type": "recent"
   260        },
   261        "retweet_count": 0,
   262        "in_reply_to_status_id_str": null,
   263        "id": 249289491129438208,
   264        "geo": null,
   265        "retweeted": false,
   266        "in_reply_to_user_id": null,
   267        "place": null,
   268        "user": {
   269          "profile_sidebar_fill_color": "99CC33",
   270          "profile_sidebar_border_color": "829D5E",
   271          "profile_background_tile": false,
   272          "name": "Thomas John Wakeman",
   273          "profile_image_url": "https://a0.twimg.com/profile_images/2219333930/Froggystyle_normal.png",
   274          "created_at": "Tue Sep 01 21:21:35 +0000 2009",
   275          "location": "Kingston New York",
   276          "follow_request_sent": null,
   277          "profile_link_color": "D02B55",
   278          "is_translator": false,
   279          "id_str": "70789458",
   280          "entities": {
   281            "url": {
   282              "urls": [
   283                {
   284                  "expanded_url": null,
   285                  "url": "",
   286                  "indices": [
   287                    0,
   288                    0
   289                  ]
   290                }
   291              ]
   292            },
   293            "description": {
   294              "urls": [
   295   
   296              ]
   297            }
   298          },
   299          "default_profile": false,
   300          "contributors_enabled": false,
   301          "favourites_count": 19,
   302          "url": null,
   303          "profile_image_url_https": "https://si0.twimg.com/profile_images/2219333930/Froggystyle_normal.png",
   304          "utc_offset": -18000,
   305          "id": 70789458,
   306          "profile_use_background_image": true,
   307          "listed_count": 1,
   308          "profile_text_color": "3E4415",
   309          "lang": "en",
   310          "followers_count": 63,
   311          "protected": false,
   312          "notifications": null,
   313          "profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme5/bg.gif",
   314          "profile_background_color": "352726",
   315          "verified": false,
   316          "geo_enabled": false,
   317          "time_zone": "Eastern Time (US & Canada)",
   318          "description": "Science Fiction Writer, sort of. Likes Superheroes, Mole People, Alt. Timelines.",
   319          "default_profile_image": false,
   320          "profile_background_image_url": "https://a0.twimg.com/images/themes/theme5/bg.gif",
   321          "statuses_count": 1048,
   322          "friends_count": 63,
   323          "following": null,
   324          "show_all_inline_media": false,
   325          "screen_name": "MonkiesFist"
   326        },
   327        "in_reply_to_screen_name": null,
   328        "source": "web",
   329        "in_reply_to_status_id": null
   330      },
   331      {
   332        "coordinates": null,
   333        "favorited": false,
   334        "truncated": false,
   335        "created_at": "Fri Sep 21 22:51:18 +0000 2012",
   336        "id_str": "249279667666817024",
   337        "entities": {
   338          "urls": [
   339   
   340          ],
   341          "hashtags": [
   342            {
   343              "text": "freebandnames",
   344              "indices": [
   345                20,
   346                34
   347              ]
   348            }
   349          ],
   350          "user_mentions": [
   351   
   352          ]
   353        },
   354        "in_reply_to_user_id_str": null,
   355        "contributors": null,
   356        "text": "The Foolish Mortals #freebandnames",
   357        "metadata": {
   358          "iso_language_code": "en",
   359          "result_type": "recent"
   360        },
   361        "retweet_count": 0,
   362        "in_reply_to_status_id_str": null,
   363        "id": 249279667666817024,
   364        "geo": null,
   365        "retweeted": false,
   366        "in_reply_to_user_id": null,
   367        "place": null,
   368        "user": {
   369          "profile_sidebar_fill_color": "BFAC83",
   370          "profile_sidebar_border_color": "615A44",
   371          "profile_background_tile": true,
   372          "name": "Marty Elmer",
   373          "profile_image_url": "https://a0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png",
   374          "created_at": "Mon May 04 00:05:00 +0000 2009",
   375          "location": "Wisconsin, USA",
   376          "follow_request_sent": null,
   377          "profile_link_color": "3B2A26",
   378          "is_translator": false,
   379          "id_str": "37539828",
   380          "entities": {
   381            "url": {
   382              "urls": [
   383                {
   384                  "expanded_url": null,
   385                  "url": "https://www.omnitarian.me",
   386                  "indices": [
   387                    0,
   388                    24
   389                  ]
   390                }
   391              ]
   392            },
   393            "description": {
   394              "urls": [
   395   
   396              ]
   397            }
   398          },
   399          "default_profile": false,
   400          "contributors_enabled": false,
   401          "favourites_count": 647,
   402          "url": "https://www.omnitarian.me",
   403          "profile_image_url_https": "https://si0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png",
   404          "utc_offset": -21600,
   405          "id": 37539828,
   406          "profile_use_background_image": true,
   407          "listed_count": 52,
   408          "profile_text_color": "000000",
   409          "lang": "en",
   410          "followers_count": 608,
   411          "protected": false,
   412          "notifications": null,
   413          "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/106455659/rect6056-9.png",
   414          "profile_background_color": "EEE3C4",
   415          "verified": false,
   416          "geo_enabled": false,
   417          "time_zone": "Central Time (US & Canada)",
   418          "description": "Cartoonist, Illustrator, and T-Shirt connoisseur",
   419          "default_profile_image": false,
   420          "profile_background_image_url": "https://a0.twimg.com/profile_background_images/106455659/rect6056-9.png",
   421          "statuses_count": 3575,
   422          "friends_count": 249,
   423          "following": null,
   424          "show_all_inline_media": true,
   425          "screen_name": "Omnitarian"
   426        },
   427        "in_reply_to_screen_name": null,
   428        "source": "<a href=\"//twitter.com/download/iphone%5C%22\" rel=\"\\\"nofollow\\\"\">Twitter for iPhone</a>",
   429        "in_reply_to_status_id": null
   430      }
   431    ],
   432    "search_metadata": {
   433      "max_id": 250126199840518145,
   434      "since_id": 24012619984051000,
   435      "refresh_url": "?since_id=250126199840518145&q=%23freebandnames&result_type=mixed&include_entities=1",
   436      "next_results": "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed",
   437      "count": 4,
   438      "completed_in": 0.035,
   439      "since_id_str": "24012619984051000",
   440      "query": "%23freebandnames",
   441      "max_id_str": "250126199840518145"
   442    }
   443  }`
   444  
   445  type TwitterStruct struct {
   446      Statuses       []Statuses     `json:"statuses"`
   447      SearchMetadata SearchMetadata `json:"search_metadata"`
   448  }
   449  
   450  type Hashtags struct {
   451      Text    string `json:"text"`
   452      Indices []int  `json:"indices"`
   453  }
   454  
   455  type Entities struct {
   456      Urls         []interface{} `json:"urls"`
   457      Hashtags     []Hashtags    `json:"hashtags"`
   458      UserMentions []interface{} `json:"user_mentions"`
   459  }
   460  
   461  type Metadata struct {
   462      IsoLanguageCode string `json:"iso_language_code"`
   463      ResultType      string `json:"result_type"`
   464  }
   465  
   466  type Urls struct {
   467      ExpandedURL interface{} `json:"expanded_url"`
   468      URL         string      `json:"url"`
   469      Indices     []int       `json:"indices"`
   470  }
   471  
   472  type URL struct {
   473      Urls []Urls `json:"urls"`
   474  }
   475  
   476  type Description struct {
   477      Urls []interface{} `json:"urls"`
   478  }
   479  
   480  type UserEntities struct {
   481      URL         URL         `json:"url"`
   482      Description Description `json:"description"`
   483  }
   484  
   485  type User struct {
   486      ProfileSidebarFillColor        string       `json:"profile_sidebar_fill_color"`
   487      ProfileSidebarBorderColor      string       `json:"profile_sidebar_border_color"`
   488      ProfileBackgroundTile          bool         `json:"profile_background_tile"`
   489      Name                           string       `json:"name"`
   490      ProfileImageURL                string       `json:"profile_image_url"`
   491      CreatedAt                      string       `json:"created_at"`
   492      Location                       string       `json:"location"`
   493      FollowRequestSent              interface{}  `json:"follow_request_sent"`
   494      ProfileLinkColor               string       `json:"profile_link_color"`
   495      IsTranslator                   bool         `json:"is_translator"`
   496      IDStr                          string       `json:"id_str"`
   497      Entities                       UserEntities `json:"entities"`
   498      DefaultProfile                 bool         `json:"default_profile"`
   499      ContributorsEnabled            bool         `json:"contributors_enabled"`
   500      FavouritesCount                int          `json:"favourites_count"`
   501      URL                            interface{}  `json:"url"`
   502      ProfileImageURLHTTPS           string       `json:"profile_image_url_https"`
   503      UtcOffset                      int          `json:"utc_offset"`
   504      ID                             int          `json:"id"`
   505      ProfileUseBackgroundImage      bool         `json:"profile_use_background_image"`
   506      ListedCount                    int          `json:"listed_count"`
   507      ProfileTextColor               string       `json:"profile_text_color"`
   508      Lang                           string       `json:"lang"`
   509      FollowersCount                 int          `json:"followers_count"`
   510      Protected                      bool         `json:"protected"`
   511      Notifications                  interface{}  `json:"notifications"`
   512      ProfileBackgroundImageURLHTTPS string       `json:"profile_background_image_url_https"`
   513      ProfileBackgroundColor         string       `json:"profile_background_color"`
   514      Verified                       bool         `json:"verified"`
   515      GeoEnabled                     bool         `json:"geo_enabled"`
   516      TimeZone                       string       `json:"time_zone"`
   517      Description                    string       `json:"description"`
   518      DefaultProfileImage            bool         `json:"default_profile_image"`
   519      ProfileBackgroundImageURL      string       `json:"profile_background_image_url"`
   520      StatusesCount                  int          `json:"statuses_count"`
   521      FriendsCount                   int          `json:"friends_count"`
   522      Following                      interface{}  `json:"following"`
   523      ShowAllInlineMedia             bool         `json:"show_all_inline_media"`
   524      ScreenName                     string       `json:"screen_name"`
   525  }
   526  
   527  type Statuses struct {
   528      Coordinates          interface{} `json:"coordinates"`
   529      Favorited            bool        `json:"favorited"`
   530      Truncated            bool        `json:"truncated"`
   531      CreatedAt            string      `json:"created_at"`
   532      IDStr                string      `json:"id_str"`
   533      Entities             Entities    `json:"entities"`
   534      InReplyToUserIDStr   interface{} `json:"in_reply_to_user_id_str"`
   535      Contributors         interface{} `json:"contributors"`
   536      Text                 string      `json:"text"`
   537      Metadata             Metadata    `json:"metadata"`
   538      RetweetCount         int         `json:"retweet_count"`
   539      InReplyToStatusIDStr interface{} `json:"in_reply_to_status_id_str"`
   540      ID                   int64       `json:"id"`
   541      Geo                  interface{} `json:"geo"`
   542      Retweeted            bool        `json:"retweeted"`
   543      InReplyToUserID      interface{} `json:"in_reply_to_user_id"`
   544      Place                interface{} `json:"place"`
   545      User                 User        `json:"user"`
   546      InReplyToScreenName  interface{} `json:"in_reply_to_screen_name"`
   547      Source               string      `json:"source"`
   548      InReplyToStatusID    interface{} `json:"in_reply_to_status_id"`
   549  }
   550  
   551  type SearchMetadata struct {
   552      MaxID       int64   `json:"max_id"`
   553      SinceID     int64   `json:"since_id"`
   554      RefreshURL  string  `json:"refresh_url"`
   555      NextResults string  `json:"next_results"`
   556      Count       int     `json:"count"`
   557      CompletedIn float64 `json:"completed_in"`
   558      SinceIDStr  string  `json:"since_id_str"`
   559      Query       string  `json:"query"`
   560      MaxIDStr    string  `json:"max_id_str"`
   561  }