github.com/bytedance/sonic@v1.11.7-0.20240517092252-d2edb31b167b/internal/native/neon/recover_arm64_test.go (about) 1 // Code generated by Makefile, DO NOT EDIT. 2 3 /** 4 * Copyright 2023 ByteDance Inc. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package neon 20 21 import ( 22 `os` 23 `time` 24 `runtime` 25 `runtime/debug` 26 `testing` 27 `unsafe` 28 29 `github.com/bytedance/sonic/internal/native/types` 30 ) 31 32 var ( 33 debugAsyncGC = os.Getenv("SONIC_NO_ASYNC_GC") == "" 34 ) 35 36 func TestMain(m *testing.M) { 37 go func () { 38 if !debugAsyncGC { 39 return 40 } 41 println("Begin GC looping...") 42 for { 43 runtime.GC() 44 debug.FreeOSMemory() 45 } 46 println("stop GC looping!") 47 }() 48 time.Sleep(time.Millisecond*100) 49 m.Run() 50 } 51 52 func TestRecover_f32toa(t *testing.T) { 53 defer func() { 54 if r := recover(); r!= nil { 55 t.Log("recover: ", r) 56 } else { 57 t.Fatal("no panic") 58 } 59 }() 60 _ = f32toa(nil, 123) 61 } 62 63 func TestRecover_f64toa(t *testing.T) { 64 defer func() { 65 if r := recover(); r!= nil { 66 t.Log("recover: ", r) 67 } else { 68 t.Fatal("no panic") 69 } 70 }() 71 _ = f64toa(nil, 123) 72 } 73 74 func TestRecover_i64toa(t *testing.T) { 75 defer func() { 76 if r := recover(); r!= nil { 77 t.Log("recover: ", r) 78 } else { 79 t.Fatal("no panic") 80 } 81 }() 82 _ = i64toa(nil, 123) 83 } 84 85 func TestRecover_u64toa(t *testing.T) { 86 defer func() { 87 if r := recover(); r!= nil { 88 t.Log("recover: ", r) 89 } else { 90 t.Fatal("no panic") 91 } 92 }() 93 _ = u64toa(nil, 123) 94 } 95 96 func TestRecover_lspace(t *testing.T) { 97 defer func() { 98 if r := recover(); r!= nil { 99 t.Log("recover: ", r) 100 } else { 101 t.Fatal("no panic") 102 } 103 }() 104 _ = lspace(nil, 2, 0) 105 } 106 107 func TestRecover_quote(t *testing.T) { 108 var dn = 10 109 var dp = make([]byte, dn) 110 var sp = []byte("123") 111 t.Run("sp", func(t *testing.T) { 112 defer func() { 113 if r := recover(); r!= nil { 114 t.Log("recover: ", r) 115 } else { 116 t.Fatal("no panic") 117 } 118 }() 119 _ = quote(nil, 3, unsafe.Pointer(&dp[0]), &dn, 0) 120 }) 121 t.Run("dp", func(t *testing.T) { 122 defer func() { 123 if r := recover(); r!= nil { 124 t.Log("recover: ", r) 125 } else { 126 t.Fatal("no panic") 127 } 128 }() 129 _ = quote(unsafe.Pointer(&sp[0]), 3, nil, &dn, 0) 130 }) 131 t.Run("dn", func(t *testing.T) { 132 defer func() { 133 if r := recover(); r!= nil { 134 t.Log("recover: ", r) 135 } else { 136 t.Fatal("no panic") 137 } 138 }() 139 _ = quote(unsafe.Pointer(&sp[0]), 3, unsafe.Pointer(&dp[0]), nil, 0) 140 }) 141 } 142 143 func TestRecover_html_escape(t *testing.T) { 144 var dn = 10 145 var dp = make([]byte, dn) 146 var sp = []byte("123") 147 t.Run("sp", func(t *testing.T) { 148 defer func() { 149 if r := recover(); r!= nil { 150 t.Log("recover: ", r) 151 } else { 152 t.Fatal("no panic") 153 } 154 }() 155 _ = html_escape(nil, 3, unsafe.Pointer(&dp[0]), &dn) 156 }) 157 t.Run("dp", func(t *testing.T) { 158 defer func() { 159 if r := recover(); r!= nil { 160 t.Log("recover: ", r) 161 } else { 162 t.Fatal("no panic") 163 } 164 }() 165 _ = html_escape(unsafe.Pointer(&sp[0]), 3, nil, &dn) 166 }) 167 t.Run("dn", func(t *testing.T) { 168 defer func() { 169 if r := recover(); r!= nil { 170 t.Log("recover: ", r) 171 } else { 172 t.Fatal("no panic") 173 } 174 }() 175 _ = html_escape(unsafe.Pointer(&sp[0]), 3, unsafe.Pointer(&dp[0]), nil) 176 }) 177 } 178 179 func TestRecover_unquote(t *testing.T) { 180 var ep = 0 181 var dp = make([]byte, 10) 182 var sp = []byte("12\\x\"3\"4") 183 t.Run("sp", func(t *testing.T) { 184 defer func() { 185 if r := recover(); r!= nil { 186 t.Log("recover: ", r) 187 } else { 188 t.Fatal("no panic") 189 } 190 }() 191 _ = unquote(nil, len(sp), unsafe.Pointer(&dp[0]), &ep, 0) 192 }) 193 t.Run("dp", func(t *testing.T) { 194 defer func() { 195 if r := recover(); r!= nil { 196 t.Log("recover: ", r) 197 } else { 198 t.Fatal("no panic") 199 } 200 }() 201 _ = unquote(unsafe.Pointer(&sp[0]), len(sp), nil, &ep, 0) 202 }) 203 t.Run("ep", func(t *testing.T) { 204 defer func() { 205 if r := recover(); r!= nil { 206 t.Log("recover: ", r) 207 } else { 208 t.Fatal("no panic") 209 } 210 }() 211 _ = unquote(unsafe.Pointer(&sp[0]), len(sp), unsafe.Pointer(&dp[0]), nil, 0) 212 }) 213 } 214 215 func TestRecover_value(t *testing.T) { 216 var v = new(types.JsonState) 217 var sp = []byte("123") 218 t.Run("sp", func(t *testing.T) { 219 defer func() { 220 if r := recover(); r!= nil { 221 t.Log("recover: ", r) 222 } else { 223 t.Fatal("no panic") 224 } 225 }() 226 _ = value(nil, 3, 0, v, 0) 227 }) 228 t.Run("v", func(t *testing.T) { 229 defer func() { 230 if r := recover(); r!= nil { 231 t.Log("recover: ", r) 232 } else { 233 t.Fatal("no panic") 234 } 235 }() 236 _ = value(unsafe.Pointer(&sp[0]), 3, 0, nil, 0) 237 }) 238 } 239 240 func TestRecover_vstring(t *testing.T) { 241 var v = new(types.JsonState) 242 var sp = "123" 243 var p = 0 244 t.Run("sp", func(t *testing.T) { 245 defer func() { 246 if r := recover(); r!= nil { 247 t.Log("recover: ", r) 248 } else { 249 t.Fatal("no panic") 250 } 251 }() 252 vstring(nil, &p, v, 0) 253 }) 254 t.Run("p", func(t *testing.T) { 255 defer func() { 256 if r := recover(); r!= nil { 257 t.Log("recover: ", r) 258 } else { 259 t.Fatal("no panic") 260 } 261 }() 262 vstring(&sp, nil, v, 0) 263 }) 264 t.Run("v", func(t *testing.T) { 265 defer func() { 266 if r := recover(); r!= nil { 267 t.Log("recover: ", r) 268 } else { 269 t.Fatal("no panic") 270 } 271 }() 272 vstring(&sp, &p, nil, 0) 273 }) 274 } 275 276 func TestRecover_vnumber(t *testing.T) { 277 var v = new(types.JsonState) 278 var sp = "123" 279 var p = 0 280 t.Run("sp", func(t *testing.T) { 281 defer func() { 282 if r := recover(); r!= nil { 283 t.Log("recover: ", r) 284 } else { 285 t.Fatal("no panic") 286 } 287 }() 288 vnumber(nil, &p, v) 289 }) 290 t.Run("p", func(t *testing.T) { 291 defer func() { 292 if r := recover(); r!= nil { 293 t.Log("recover: ", r) 294 } else { 295 t.Fatal("no panic") 296 } 297 }() 298 vnumber(&sp, nil, v) 299 }) 300 t.Run("v", func(t *testing.T) { 301 defer func() { 302 if r := recover(); r!= nil { 303 t.Log("recover: ", r) 304 } else { 305 t.Fatal("no panic") 306 } 307 }() 308 vnumber(&sp, &p, nil) 309 }) 310 } 311 312 func TestRecover_vsigned(t *testing.T) { 313 var v = new(types.JsonState) 314 var sp = "123" 315 var p = 0 316 t.Run("sp", func(t *testing.T) { 317 defer func() { 318 if r := recover(); r!= nil { 319 t.Log("recover: ", r) 320 } else { 321 t.Fatal("no panic") 322 } 323 }() 324 vsigned(nil, &p, v) 325 }) 326 t.Run("p", func(t *testing.T) { 327 defer func() { 328 if r := recover(); r!= nil { 329 t.Log("recover: ", r) 330 } else { 331 t.Fatal("no panic") 332 } 333 }() 334 vsigned(&sp, nil, v) 335 }) 336 t.Run("v", func(t *testing.T) { 337 defer func() { 338 if r := recover(); r!= nil { 339 t.Log("recover: ", r) 340 } else { 341 t.Fatal("no panic") 342 } 343 }() 344 vsigned(&sp, &p, nil) 345 }) 346 } 347 348 func TestRecover_vunsigned(t *testing.T) { 349 var v = new(types.JsonState) 350 var sp = "123" 351 var p = 0 352 t.Run("sp", func(t *testing.T) { 353 defer func() { 354 if r := recover(); r!= nil { 355 t.Log("recover: ", r) 356 } else { 357 t.Fatal("no panic") 358 } 359 }() 360 vunsigned(nil, &p, v) 361 }) 362 t.Run("p", func(t *testing.T) { 363 defer func() { 364 if r := recover(); r!= nil { 365 t.Log("recover: ", r) 366 } else { 367 t.Fatal("no panic") 368 } 369 }() 370 vunsigned(&sp, nil, v) 371 }) 372 t.Run("v", func(t *testing.T) { 373 defer func() { 374 if r := recover(); r!= nil { 375 t.Log("recover: ", r) 376 } else { 377 t.Fatal("no panic") 378 } 379 }() 380 vunsigned(&sp, &p, nil) 381 }) 382 } 383 384 func TestRecover_skip_one(t *testing.T) { 385 var v = types.NewStateMachine() 386 var sp = "123" 387 var p = 0 388 t.Run("sp", func(t *testing.T) { 389 defer func() { 390 if r := recover(); r!= nil { 391 t.Log("recover: ", r) 392 } else { 393 t.Fatal("no panic") 394 } 395 }() 396 _ = skip_one(nil, &p, v, 0) 397 }) 398 t.Run("p", func(t *testing.T) { 399 defer func() { 400 if r := recover(); r!= nil { 401 t.Log("recover: ", r) 402 } else { 403 t.Fatal("no panic") 404 } 405 }() 406 _ = skip_one(&sp, nil, v, 0) 407 }) 408 t.Run("v", func(t *testing.T) { 409 defer func() { 410 if r := recover(); r!= nil { 411 t.Log("recover: ", r) 412 } else { 413 t.Fatal("no panic") 414 } 415 }() 416 _ = skip_one(&sp, &p, nil, 0) 417 }) 418 } 419 420 func TestRecover_skip_one_fast(t *testing.T) { 421 var sp = "123" 422 var p = 0 423 t.Run("sp", func(t *testing.T) { 424 defer func() { 425 if r := recover(); r!= nil { 426 t.Log("recover: ", r) 427 } else { 428 t.Fatal("no panic") 429 } 430 }() 431 _ = skip_one_fast(nil, &p) 432 }) 433 t.Run("p", func(t *testing.T) { 434 defer func() { 435 if r := recover(); r!= nil { 436 t.Log("recover: ", r) 437 } else { 438 t.Fatal("no panic") 439 } 440 }() 441 _ = skip_one_fast(&sp, nil) 442 }) 443 } 444 445 func TestRecover_skip_array(t *testing.T) { 446 var v = types.NewStateMachine() 447 var sp = "123" 448 var p = 0 449 t.Run("sp", func(t *testing.T) { 450 defer func() { 451 if r := recover(); r!= nil { 452 t.Log("recover: ", r) 453 } else { 454 t.Fatal("no panic") 455 } 456 }() 457 _ = skip_array(nil, &p, v, 0) 458 }) 459 t.Run("p", func(t *testing.T) { 460 defer func() { 461 if r := recover(); r!= nil { 462 t.Log("recover: ", r) 463 } else { 464 t.Fatal("no panic") 465 } 466 }() 467 _ = skip_array(&sp, nil, v, 0) 468 }) 469 t.Run("v", func(t *testing.T) { 470 defer func() { 471 if r := recover(); r!= nil { 472 t.Log("recover: ", r) 473 } else { 474 t.Fatal("no panic") 475 } 476 }() 477 _ = skip_array(&sp, &p, nil, 0) 478 }) 479 } 480 481 func TestRecover_skip_object(t *testing.T) { 482 var v = types.NewStateMachine() 483 var sp = "123" 484 var p = 0 485 t.Run("sp", func(t *testing.T) { 486 defer func() { 487 if r := recover(); r!= nil { 488 t.Log("recover: ", r) 489 } else { 490 t.Fatal("no panic") 491 } 492 }() 493 _ = skip_object(nil, &p, v, 0) 494 }) 495 t.Run("p", func(t *testing.T) { 496 defer func() { 497 if r := recover(); r!= nil { 498 t.Log("recover: ", r) 499 } else { 500 t.Fatal("no panic") 501 } 502 }() 503 _ = skip_object(&sp, nil, v, 0) 504 }) 505 t.Run("v", func(t *testing.T) { 506 defer func() { 507 if r := recover(); r!= nil { 508 t.Log("recover: ", r) 509 } else { 510 t.Fatal("no panic") 511 } 512 }() 513 _ = skip_object(&sp, &p, nil, 0) 514 }) 515 } 516 517 func TestRecover_skip_number(t *testing.T) { 518 var sp = "123" 519 var p = 0 520 t.Run("sp", func(t *testing.T) { 521 defer func() { 522 if r := recover(); r!= nil { 523 t.Log("recover: ", r) 524 } else { 525 t.Fatal("no panic") 526 } 527 }() 528 _ = skip_number(nil, &p) 529 }) 530 t.Run("p", func(t *testing.T) { 531 defer func() { 532 if r := recover(); r!= nil { 533 t.Log("recover: ", r) 534 } else { 535 t.Fatal("no panic") 536 } 537 }() 538 _ = skip_number(&sp, nil) 539 }) 540 } 541 542 func TestRecover_get_by_path(t *testing.T) { 543 var v = []interface{}{} 544 var sp = "123" 545 var p = 0 546 var m = types.NewStateMachine() 547 t.Run("sp", func(t *testing.T) { 548 defer func() { 549 if r := recover(); r!= nil { 550 t.Log("recover: ", r) 551 } else { 552 t.Fatal("no panic") 553 } 554 }() 555 _ = get_by_path(nil, &p, &v, m) 556 }) 557 t.Run("p", func(t *testing.T) { 558 defer func() { 559 if r := recover(); r!= nil { 560 t.Log("recover: ", r) 561 } else { 562 t.Fatal("no panic") 563 } 564 }() 565 _ = get_by_path(&sp, nil, &v, m) 566 }) 567 t.Run("path", func(t *testing.T) { 568 defer func() { 569 if r := recover(); r!= nil { 570 t.Log("recover: ", r) 571 } else { 572 t.Fatal("no panic") 573 } 574 }() 575 _ = get_by_path(&sp, &p, nil, m) 576 }) 577 } 578 579 func TestRecover_validate_one(t *testing.T) { 580 var v = types.NewStateMachine() 581 var sp = "123" 582 var p = 0 583 t.Run("sp", func(t *testing.T) { 584 defer func() { 585 if r := recover(); r!= nil { 586 t.Log("recover: ", r) 587 } else { 588 t.Fatal("no panic") 589 } 590 }() 591 _ = validate_one(nil, &p, v) 592 }) 593 t.Run("p", func(t *testing.T) { 594 defer func() { 595 if r := recover(); r!= nil { 596 t.Log("recover: ", r) 597 } else { 598 t.Fatal("no panic") 599 } 600 }() 601 _ = validate_one(&sp, nil, v) 602 }) 603 t.Run("v", func(t *testing.T) { 604 defer func() { 605 if r := recover(); r!= nil { 606 t.Log("recover: ", r) 607 } else { 608 t.Fatal("no panic") 609 } 610 }() 611 _ = validate_one(&sp, &p, nil) 612 }) 613 } 614 615 func TestRecover_validate_utf8(t *testing.T) { 616 var v = types.NewStateMachine() 617 var sp = string([]byte{0xff, 0xff, 0xff}) 618 var p = 0 619 t.Run("sp", func(t *testing.T) { 620 defer func() { 621 if r := recover(); r!= nil { 622 t.Log("recover: ", r) 623 } else { 624 t.Fatal("no panic") 625 } 626 }() 627 _ = validate_utf8(nil, &p, v) 628 }) 629 t.Run("p", func(t *testing.T) { 630 defer func() { 631 if r := recover(); r!= nil { 632 t.Log("recover: ", r) 633 } else { 634 t.Fatal("no panic") 635 } 636 }() 637 _ = validate_utf8(&sp, nil, v) 638 }) 639 t.Run("v", func(t *testing.T) { 640 defer func() { 641 if r := recover(); r!= nil { 642 t.Log("recover: ", r) 643 } else { 644 t.Fatal("no panic") 645 } 646 }() 647 _ = validate_utf8(&sp, &p, nil) 648 }) 649 } 650 651 func TestRecover_validate_utf8_fast(t *testing.T) { 652 defer func() { 653 if r := recover(); r!= nil { 654 t.Log("recover: ", r) 655 } else { 656 t.Fatal("no panic") 657 } 658 }() 659 _ = validate_utf8_fast(nil) 660 }