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