Test for segfault in factorize (gh12666)
- [x] closes #12666 
- [x] tests added / passed
- [ ] passes `git diff upstream/master | flake8 --diff`

Not sure about the last. It's my first PR. 

## [Current coverage](https://codecov.io/gh/pydata/pandas/pull/14112?src=pr) is 85.26% (diff: 100%)

> Merging [#14112](https://codecov.io/gh/pydata/pandas/pull/14112?src=pr) into [master](https://codecov.io/gh/pydata/pandas/branch/master?src=pr) will not change coverage

``` diff
@@             master     #14112   diff @@
==========================================
  Files           139        139          
  Lines         50502      50502          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          43062      43062          
  Misses         7440       7440          
  Partials          0          0          
```

> Powered by [Codecov](https://codecov.io?src=pr). Last update [8d1646c...8a6ab59](https://codecov.io/gh/pydata/pandas/compare/8d1646c36a289e3fe921aeeb5fd5ab60c7a10ae7...8a6ab59881b1574fb283b318c0bc9f892f0a7ba2?src=pr)
 thanks!
